5

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.

6
  • what does which -a python output? Commented Jun 14, 2016 at 11:29
  • /usr/local/bin/python /usr/bin/python Commented Jun 14, 2016 at 11:31
  • try python -m pip install numpy. Commented Jun 14, 2016 at 11:32
  • 3
    I would recommend you start using virtualenv, which allows you to easily control (and reproduce) combinations of interpreters and installed packages. Commented Jun 14, 2016 at 11:34
  • 1
    @cel Error: /usr/local/bin/python: No module named pip Commented Jun 14, 2016 at 11:36

2 Answers 2

7

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
Sign up to request clarification or add additional context in comments.

Comments

4
sudo pip2 install numpy==1.15.0

You need to specify numpy version because latest version requires Python version >= 3.5.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.