My Mac computer has Python 3.6 and Python 2.7 and I have successfully installed the basic modules such as numpy, scipy and matplotlib, for example, by doing the routine pip install and pip3 install. My Python 3.6 works totally well in Anaconda-Jupiter-Notebook, IDLE and Terminal, while Python 2.7 works only in terminal but not in IDLE.
Then for version check I tried
pip --version
Returning:
pip 10.0.1 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip (python 2.7)
pip3 --version
Returning:
pip 10.0.1 from /Users/son520804/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
Then,
which python2
Returning:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2
which pip2
Returning:
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip2
How could I resolve this issue and enable the Python 2.7 idle to import the modules? Much appreciated for your help.
find / -iname '*numpy*'
This is a terminal operation not a python command, you can try running that in the terminal to see where it's storing numpy, but you'll probably get the python3's version.
Try:
pip2 uninstall numpy
Then:
pip2 install numpy
It might be due to your machine seeing python3 as your default "python" so pip might actually be installing it again to python3. By denoting pip2 it should be linked to python2 (might actually need to do 'pip2.7'). Hope it helps!
Perhaps your pip is an alias to pip3. Find it out by pip --version and if so install packages for python 2.7 as pip2.7 install matplotlib
Related
I installed Ubuntu 20.04, and python3 (3.8) is installed by default.
To install python3.9, I executed:
sudo apt install python3.9
Thus, I have two versions of Python at my laptop: 3.8 and 3.9.
I'm trying to launch the simple script:
import numpy
With Python 3.8 it works correctly. But, when I interp my script by Python 3.9 the error occurs:
How to solve this problem?
I've already tried to update numpy using pip, nothing has happened.
pip3 install numpy --upgrade
Likely what is happening here is, because you have 2 versions of python installed, your pip3 command is only installing things for one of the versions, 3.8 in this case.
Specifying the python version you want to run your command with will help solve this issue.
For example,
python3.9 -m pip install numpy
or
python3.8 -m pip install numpy
You can install a package for a specific version of Python with
python3.9 -m pip install numpy
For a more consistent python environment look at python venv or a container.
I am trying to update the module vpython to the most current version. I run:
pip3 install --user vpython --upgrade
in a Jupyter terminal. This gives the error:
ERROR: jupyter-server-proxy requires Python '>=3.5' but the running Python is 3.4.2
But when I run:
python3 --version
it returns:
Python 3.5.2 :: Anaconda 4.1.1 (64-bit)
Is there something going wrong with the installed Python3 kernel for Jupyter?
Change the environmental variable in your control panel just a simple conflict between python 3.4 and 3.5 this will surely solve your issue.
The issue is that you are using pip3 which is not always tied to the specified python you are trying to run. pip is a module installed with each python3 instance, so to specify it to install to a python environment, use the -m flag:
python -m pip install <module>
Where python is the python that you expect. For instance, if you want it to run against the installation that you use through python3, then you would do python3 -m pip install <module>. This makes things easy to track, since if you want to see which python you are installing to, you can use python -m pip -V. On my machine that outputs:
pip 19.3.1 from /Users/mm92400/anaconda3/lib/python3.6/site-packages/pip (python 3.6)
I'm on Ubuntu and I have python2.7, (it came pre-installed) python3.4, (used before today) and python3.5, which I upgraded to today, installed in parallel. They all work fine on their own.
However, I want to use pip to install some packages, and I can't figure out how to do this for my 3.5 installation because pip installs for 2.7 and pip3 installs python 3.4 packages.
For instance, I have asyncio installed on 3.4, but I can't import it from 3.5. When I do pip3 install aysncio, it tells me the requirement is already satisfied.
I'm a bit of a newbie, but I did some snooping around install directories and couldn't find anything and I've googled to no avail.
I suppose you can run pip through Python until this is sorted out. (https://docs.python.org/dev/installing/)
A quick googling seems to indicate that this is indeed a bug. Try this and report back:
python3.4 -m pip --version
python3.5 -m pip --version
If they report different versions then I guess you're good to go. Just run python3.5 -m pip install package instead of pip3 install package to install 3.5 packages.
Another way would be to setup a virtual environment:
$ python3.4 -m venv envdir
$ source envdir/bin/activate
$ pip --version
Obviously, this won't install the packages globally and you'll have to source venv/bin/activate every time you wan to make use of it.
OSX: 10.9.5
PyCharm: 4.5
I am working on project in PyCharm IDE, using the 2.7.3 Python interpreter and need to import thepsycopg2 module. I tried to install the module with PyCharm, but it failed and asked me to do it manually:
Image of error message
So I typed that command in the bash shell, the module installed and now it shows up in the project interpreter 2.7.2 but not in 2.7.3 !!!!!
Maybe the pip version is too old? I upgraded pip from the bash shell: pip install --upgrade pip
python 2.7.2 shows version 7.1.0
python 2.7.3 shows version 1.5.6
You should open Preferenes > Project: (projectname) > Project Interpreter.
Choose the interpreter you want from the dropdown. If you have installed Python with Homebrew, as I have, then you maybe want to choose one of the python interpreters from the Cellars to ease usage of other packages you may have installed with Homebrew.
It might simply be that your system doesn't have pip installed, only pip3.
My system only showed me having pip3 not pip.
Use which pip3 and which pip to see if you have either.
I decided to update pip3, first trying pip3 install --upgrade pip3 which, oddly, returned: ERROR: No matching distribution found for pip3
Next, I ran pip3 install --upgrade pip and now PyCharm can install packages from the GUI.
You didn't specify what pip version you have. My guess is that the pip version is too old and PyCharm passing some flag which returns deprecation warning which cause it to fail. Try updating pip: pip install --upgrade pip
After an hour search, I have found no answer.
My Mac came with Python 2.7, but I have decided to upgrade to python 3.4.
I installed python 3.4 from python.org.
I can now use python 3.4 from terminal.
Pip still tries to download python 2.7 packages - numpy for 2.7 is "up to date".
When I try to --upgrade a package, for example numpy, I get "no permission" error. With sudo appended, the output is trash.
How can I let pip know that I am interested in packages for python 3.4?
Requirement already up-to-date: numpy in /Library/Python/2.7/site-packages
That's the problem. I want numpy to be up-to-date with Python 3.4.
You should be able to call a specific pip for your install, although it depends on which version you are running:
Starting at version 0.8:
pip-3.4 install numpy
and starting at version 1.5:
pip3.4 install numpy
If you don't have these, you should be able to just download pip and reinstall it, just be sure to call python 3.4 when you run the installer.
I would suggest to install a package manager such as macports brew and install the updated python version from them. After the latest version of python is setup use pip to install the version of numpy
In mac ports , you are able to select the default system python without messing with the path your self.
I would use Homebrew:
brew install python3
This should install Python3.4.1. Then to get pip:
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python3 get-pip.py
# Upgrade just in case...
pip3 install -U pip
Then use:
pip3 install numpy
And to run Python, use:
python3
(I only have one Python 3 installation, if you have multiple you'll need to be more specific with the version number)