python package panda not working opensuse leap 42.3 - python

I installed opensuse leap 42.3. Python 2.7.13 was also installed with it. I tried to install pandas and various other packages by
pip install pandas
It installed pandas for python 3.4 which is not installed in my system. So python programs with
import pandas
is not running with python 2.7
What should I do now ? Uninstalling python2.7 is not recommended as it came with os. If I install python 3.4, how should I avoid conflicts between two pythons while compiling any program.

Depending on your installation, you could try installing with pip2 instead of with pip.
This should specifiy that the installation refers to python 2.x, similar to how pip3 refers to python 3.x versions.
Thus use
pip2 install pandas
Using pip just defaults to one of these versions (most likely 3.x), which can result in unwanted behaviour. Although it is unlikely that this was the default if python 3.4 was not installed. Are you sure that this is the case?
This is mainly convention, so it is possible that it might not work on your device unfortunately.
To answer the second part of your question, conda is an excellent package manager/virtual environment that allow you to install and use as many different versions of python, with as many different packages as you want.

Related

When I try to install PySimpleGUI (4.53.0) in jupyter notebook using Python 3.8 the error "no module named 'PySimpleGUI' is returned

I have already used pip install pysimplegui, using pip list shows that it is installed in Terminal (I use a mac). I also made sure it was the most recent version of pysimplegui.
I'm newer to coding some I'm not sure what other information to put here. Any advice would be enormously helpful. I am using Jupyter Notebook through Anaconda.
I should add that before this I tried doing the same thing with easygui and had the exact same error.
In the anaconda terminal use python -m pip install PySimpleGUI so you install it in the python being used.
Mixing pip install and conda install is not to recommend, although sometimes unavoidable. What has happened in your case is not related to this conflict, though. In this case, the wrong pip was invoked when installing the package, so it was installed for a different python interpreter than the one you're using to run the notebook. You can have several python versions installed globally, both python(2) and python3. Furthermore, you may have even more versions of python in virtual environments, so you need to pay attention to which version you want to install a package for.
In case you don't have any specific reason not to, you'll save yourself some future headaches by using the conda package management system over pip to avoid those situations where they don't play nice with each other and you end up with a broken or unpredictable package setup.
Note that I'm not saying conda is better than pip in any way, I'm only proposing going with conda since you're using the Anaconda environment and its preinstalled packages already.
copy from PySimpleGUI
https://pysimplegui.readthedocs.io/en/latest/
Warning - tkinter + Python 3.7.3 and later, including 3.8 has problems
The version of tkinter that is being supplied with the 3.7.3 and later versions of Python is known to have a problem with table colors. Basically, they don't work. As a result, if you want to use the plain PySimpleGUI running on tkinter, you should be using 3.7.2 or less. 3.6 is the version PySimpleGUI has chosen as the recommended version for most users.

Importing packages from python 2.7 to 3.7

I was using Python 3.7 on my Mac (version 10.12.6), even though my default is python 2.7. None of my import statements were working (import cv2, import Pyautogui) when I looked back and realized that I had downloaded the packages to python2.7. how do I reinstall or move these packages to 3.7, I'm hoping to make python 3.7 my primary module. if I could make them automatically go to 3.7 that would be great as well. I am required to use '--user' for may of my PIP statements so I don't know if you can use two '--' statements together. Thanks.
If you have both Python 2 and Python 3 installed then you can access the PIP of Python 3 with the command python3 -m pip install SomePackage.
Please note, some packages might not be available for Python 3. Other packages might behave differently. Consider virtual environments like conda or venv for your work.

How to delete extra pythons on Mac OS X Sierra

In the usr/bin folder, there are three versions of Pythons installed: Python, Python2.6, Python2.7 (the folder names) - not sure what version is for Python folder.
My issue, originally, was that I tried to install the module 'pandas' to run a script, python keeps telling me pandas could not be found.
'pip freeze' shows me pandas is already installed.
However, I could not find pandas using python>>help>>modules.
So I suspected there are multiple pythons installed causing pip installing for one of them, but the default python is a different one.
So my questions are -
1 Which python is the default one that comes with macOS Sierra? (I can confirm pandas currently is installed for Python, not Python2.6 or Python2.7)
2 Can I remove extra Pythons that do not have pandas?
3 How can I find what it the default Python when I type 'Python...' and how to install pandas for that python?
Solved:
Thanks for the comments and reply.
I used "python2.7 install pip" to install pip for python2.7. Then I used command 'pip2.7 install pandas'. This way, pandas is installed for the default python. (The command 'pip install pandas' on my machine, is installing for python 2.6.)
macOS Sierra uses Python 2.7 by default.
You can uninstall a version of Python as described here. However, you shouldn't need to as long as you are managing your packages and environments. If you want to maintain more control over your projects and their packages/versions, you should take a look at virtualenv. Virtualenv creates environments that have their own installation directories that don't share packages with other virtualenv environments. This is a very popular option many people use when managing projects.
You can use pip --version to see which version of Python you are installing a package for. You can also use pip list to see which packages are currently installed.
I highly recommend taking a look at virtualenv as it'll make keeping track of Python environments and their respective packages a lot easier.
Hope this helps!

Does the python.org installer of python come with pip, and how do I use it?

I can download python 2.7.12 from python.org, and all python versions from 2.7.9 onwards are supposed to come with pip, but after installing it, using pip in the terminal does not work.
I am on macOS.
Have I installed pip, and if I have, how do I use it?
Here you have informations about pip:
https://packaging.python.org/installing/
normally python from python.org come with pip, maybe you should just update...
to update from terminal:
pip install -U pip setuptools
After when you need to install package, for example numpy, just do in a terminal:
pip install numpy
more informations here :
https://pip.pypa.io/en/stable/reference/pip_install/
you can also use conda install from anaconda as an alternative of pip :
http://conda.pydata.org/docs/get-started.html
Multiple instances of Python can coexist on your machine. Thus you could have installed Python 2.7.12 yet, when you call Python from terminal, you may be calling an older version.
To know which version you are using, type which python in terminal and look at its path. Then from Python in terminal, type
import sys
print(sys.version)
to get the exact version.
As Dadep says, I would recommend using conda to isolate your invironments if you have to play with multiple Python interpreters. Further conda simplifies 3rd party package installation process beyond doubt.

pip install packages for python 3

I don't know what I have did but now when use pip to install a package it install it for python 3 (python3.3 folder) not for python2.7.
Another problem I installed django_debug_toolbar and now my django version is 1.6.4 not 1.3 I installed.
Now I can't remove django 1.6.4 with pip. Do you have a solution?
Learn using virtualenv. It allows you to have different environments with isolated version of Python and set of installed packages. Each created virtual environment is by default having pip installed.
You messed up things (as you know very well) as you probably reinstalled pip for another version of Python.
You might find more versions of pip in your system. Check the version of python they use (on Linux watch the shebang on first line). Use explicit path to proper pip to manage packages for related Python.
Often people install pip and rename it or give an alias - names like pip33 or pip27.
Note, that virtualenv allows creation of different environments (with different Python versions) without need to install virutalenv for each of these Pythons.
With virtualenv I would also highly recommend using virtualenvwrapper which adds a few very handy commands.
My problem came when I installed django_debug_toolbar. when I pip-installed django-debug-toolbar, the latest version of Django was installed automatically.

Categories