I have been literally struggling to install numpy for python 2.7 and not 3.4 both of which are on my ubuntu. I have tried:
sudo pip2 install numpy
but it says
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/lib/python2.7/dist-packages
but when I go to the python shell, and type import numpy, it throws an ImportError
python --version prints `Python 2.7.5`
I have no idea what the problem is even after looking at various answers to other SO questions. Is numpy installed and I'm not able to use it for some reason or isn't it installed? Please help.
First, do pip uninstall numpy and pip2 uninstall numpy just to clean up any old files.
Then, since you are on Ubuntu, you should just run
sudo apt-get install python-numpy
This will install numpy for python2. If you later choose you want it for python3, just run
sudo apt-get install python3-numpy
sudo pip2 install numpy==1.15.0
You need to specify numpy version because latest version requires Python version >= 3.5.
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.
Today, I have decided to upgrade my software packages:
sudo apt-get upgrade
After that, I am trying to launch my python2 code and the error appears:
ImportError: No module named numpy
I have tried pip install numpy, but got a message
Requirement already satisfied: numpy in /home/user/anaconda3/lib/python3.5/site-packages (1.15.1)
pip2 install numpy produces an exception:
pkg_resources.VersionConflict: (pip 18.0 (/usr/local/lib/python3.5/dist-packages), Requirement.parse('pip==8.1.1'))
conda install numpy results in
# All requested packages already installed.
which python gives me
/home/user/anaconda3/bin/python
which pip results in
/home/user/anaconda3/bin/pip
What could be the problem? Seems like numpy cannot be installed for python2 because it is already installed for python3. I suppose, something went wrong with python2 vs python3 linkage in conda? Is it a problem with python, numpy, pip, conda or environments?
I have brew install python2 for OsX, then I install numpy, scipy using pip install.
I also need python3, so I brew install python3, but when I import numpy under python3, import error occurs.
I known I can fix this by install numpy using pip3 install numpy, but do I have to do this? Since I have the package already installed for python2, can I just tell python3 where it is and then use it?
Yes you need to install them using pip3 as well as python3.4 bundles pip in along side of python
I am able to install tensorflow for python using pip just fine but when I try and install tensorflow for pypy using:
pypy -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
I get error messages about how pypy doesn't play well with numpy. I already have numpy installed for pypy and it workes fine. I can do
pypy
>>>>import numpy
without any errors.
What am I doing wrong here? Is there a way to try and install tensorflow without it trying to install numpy? Has anyone done this before?
youcan use directly pip
example: Mac OS X, CPU only - py2
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/tensorflow-0.9.0-py2-none-any.whl
sudo pip install --upgrade $TF_BINARY_URL
If you need validate pip installation:
sudo easy_install pip
sudo easy_install --upgrade six
If you need info for other SO or more details you can see here
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)