简体   繁体   中英

Install numpy for python 2.7 and not 3.4

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

您需要指定 numpy 版本,因为最新版本需要 Python 版本 >= 3.5。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM