Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 636
Sibi Avatar asked Jun 14 '16 11:06

Sibi


1 Answers

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
like image 75
Giorgian Borca-Tasciuc Avatar answered Sep 29 '22 18:09

Giorgian Borca-Tasciuc