2

First of all I know this subject is duplicate, but if I understood the problem, I wouldn't come here to ask my question.

I read
Explain why numpy should not be imported from source directory and probably 2^6 other sites/questions/solution (pip etc..) with similar issues, but I still don't understand. I'm a beginner, I have no problem when I update library of python on ubuntu, but on windows, I've lost my nerves.

So I will explain the way I update my library :

I go on https://github.com/numpy/numpy/releases

I take the v.1.11.0 (the zip)

I get the file numpy-1.11.0.zip in downloads

I delete the file 'numpy' in C:\Python27\Lib\site-packages

I put my new file numpy-1.11.0.zip in site-packages

I unzip that file.

I click on all of the .py of that upzip file

When I try to compile my code (which work on previous version of numpy), I get an error:

ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python intepreter from there.

Where did I fail to update my numpy library? Could someone explain to me in a simple way, because I'm really a noob.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Cass
  • 144
  • 1
  • 1
  • 13
  • Have you tried to update it using pip? If so, what happens? Or do you not know how to use pip at all? – DavidG Jul 12 '16 at 11:56
  • No i haven't try with pip because i don't know how install on Windows, i try : 'python -m pip install -U pip' but Windows don't recognize python as a intern command – Cass Jul 12 '16 at 12:10
  • i get : `[33mRetrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/pip/[0m [31mOperation cancelled by user[0m`, when i try to install pip so i don't use that solution – Cass Jul 12 '16 at 12:21
  • What version of Python are you using? – DavidG Jul 12 '16 at 13:15
  • I use the version 2.7.9 – Cass Jul 12 '16 at 13:25

2 Answers2

7

Pip is the easiest way to go installing packages. Your first problem appears to be that windows isn't recognising python as a command. In order to fix this you need to add it to the PATH environment variable.

  1. Open Start Menu and right click My Computer. Click on Advanced System Settings.
  2. Click on Environment Variables
  3. Find the PATH variable and click Edit. You want to add Python to this PATH variable by adding exactly ;C:\Python27

According to the documentation your version of Python, 2.7.9, should come with pip installed so no need for you to do anything there.

Open the command prompt and type pip install --upgrade numpy and it should upgrade to the newest version.

DavidG
  • 24,279
  • 14
  • 89
  • 82
1

Both numpy and scipy have problems installing from pypi (the default repository of pip) on windows. The way I always install it it to download the .whl files from Christoper Gohlke's site and install them with pip.

For example, if you are running Python 3.5 on a 64 bit machine:

  • Start by downloading numpy-1.11.1+mkl-cp35-cp35m-win_amd64.whl from the site linked above
  • After the download is finished, open a powershell window and cd to your python scripts directory (mine is C:\\Python35\Scripts).
  • From there you can use pip to install the whl file with pip install C:\Users\USERNAME\Downloads\numpy-1.11.1+mkl-cp35-cp35m-win_amd64.whl
Chris Mueller
  • 6,490
  • 5
  • 29
  • 35
  • Thanks a lot for the detailled explication of your steps ! I will keep your solution too. – Cass Jul 12 '16 at 14:40