Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install numpy to Python 3.5?

Tags:

python

pip

numpy

I'm attempting to install numpy on python3.5 via :

python3.5 -m pip install numpy

but receive error :

/usr/local/bin/python3.5: No module named pip

Same error for pip3 :

python3.5 -m pip3 install numpy
/usr/local/bin/python3.5: No module named pip3

Reason I'm attempting to install numpy this way is pip3 is pointing to a 3.4 dist-packages dir :

pip3 install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python3.4/dist-packages
Cleaning up..

How to install numpy to Python 3.5 ?

Update:

I decided to use docker in order to install on a clean ubuntu14.04 environment and it worked out of box.

like image 377
blue-sky Avatar asked Jan 20 '17 22:01

blue-sky


2 Answers

Although using virtual environment is advisable in many use-cases, it is not strictly required. You can have a system python3.5 and a pip installation associated with it.

Note that Python 3.5 is now end-of-life and pip has now dropped support. The final version of pip supporting Python 3.5 was 20.3.4 (Jan 2021).

  1. Download this file: pip-20.3.4-py2.py3-none-any.whl
  2. Bootstrap a pip installation using the wheel file: sudo python3.5 pip-20.3.4-py2.py3-none-any.whl/pip install pip-20.3.4-py2.py3-none-any.whl
  3. Install numpy with python3.5 -m pip install --user numpy
like image 100
wim Avatar answered Oct 22 '22 01:10

wim


I strongly recommend using a virtual environment and in the case of the scientific Python stack, I further recommend using anaconda. It will save you loads of headaches in the future.

  1. Download anaconda for Python3.5.
  2. Create an environment.
  3. Activate it.
  4. conda install numpy.

Step 2 looks like this:

conda create --name env_name numpy

Step 3 looks like this:

source activate env_name

Step 4 looks like this:

conda install numpy

Now, anytime you want to use numpy or any other dependency in your environment, you just do source activate env_name.

To deactivate, do:

source deactivate
like image 45
erewok Avatar answered Oct 22 '22 01:10

erewok