29

I want to install NumPy using the pip install numpy command, but I get the following error:

RuntimeError: Broken toolchain: cannot link a simple C program

I'm using Windows 7 32 bit, Python 2.7.9, pip 6.1.1 and some MSVC compiler. I think it uses the compiler from Visual C++ 2010 Express, but actually I'm not sure which one, because I have several Visual Studio installations.

I know that there are prebuilt packages for Windows, but is there some way to do it just by typing pip install numpy?

I think that there could be other packages which must be compiled before usage, so it's not only about NumPy. I want to solve the problem with my compiler, so I could easily install any other similar package without necessity to search for prebuilt packages (and hope that there are some at all).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
QNA
  • 1,047
  • 2
  • 14
  • 26
  • 2
    as per @leewz 's response, I can verify that pip install numpy works on windows platform. – pandamakes Dec 17 '16 at 09:10
  • The canonical question for this problem on Windows may be *[Error "Import Error: No module named numpy" on Windows](https://stackoverflow.com/questions/7818811/)* (2011, 40 answers and 300 votes). – Peter Mortensen Aug 22 '22 at 15:06

8 Answers8

33

Check the installation of Python 2.7, and then install/reinstall pip which is described here. Then a open command line windows and write:

pip install numpy

Or

pip install scipy

If already installed, try this:

pip install -U numpy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
acs
  • 796
  • 2
  • 14
  • 33
  • 1
    Thanks. Yes I can install anaconda and make my life easy in the short term but 1) I like to know what all is being installed on my machine 2) I rather know the hard way to do it in case I have to install a package that's not included in anaconda. – Pete May 21 '16 at 22:40
  • Oh and the process completed smoothly (windows 7). It also told me that a newer version was available and the command I should run to upgrade it. – Pete May 21 '16 at 22:42
  • it was weird, I tried `pip install numpy` it said __Requirement already satisfied: numpy__, I tried `pip install -U numpy` it said __Can't uninstall 'numpy'. No files were found to uninstall__ but then it continued installation __Successfully installed numpy-1.15.3__ and finally it started to work... – user924 Oct 29 '18 at 11:17
  • you should check the python version – acs Nov 01 '18 at 09:50
26

Installing extension modules can be an issue with pip. This is why Conda exists. Conda is an open-source BSD-licensed cross-platform package manager. It can easily install NumPy.

Two options:

  • Install Anaconda here
  • Install Miniconda here and then go to a command line and type conda install numpy (make sure your PATH includes the location Conda was installed to).
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Akhilesh Shukla
  • 308
  • 2
  • 4
  • 2
    This article (https://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/) provides lots of detail on how pip and conda work together, and why conda was created to supplement pip (e.g. to install non-Python packages, which pip can't do, and to be an environment manager as well, like virtualenv) – Sean McCarthy Jan 07 '19 at 00:34
  • ATTENTION, if your errors include 'AttributeError: module 'numbers' has no attribute 'Integral' you don't need to install numpy. The problem is that you have a file in your folder called numbers.py to fix the problem simply rename your file name to my_numbers.py and numpy will work for you. –  Dec 04 '21 at 23:33
22

Frustratingly, the NumPy package published to PyPI won't install on most Windows computers: Windows wheel package (.whl) on Pypi #5479

Instead:

  1. Download the NumPy wheel for your Python version from Archived: Unofficial Windows Binaries for Python Extension Packages, NumPy

  2. Install it from the command line:

    pip install numpy-1.10.2+mkl-cp35-none-win_amd64.whl
    
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
  • 3
    Thank you for this—if I have Python already installed on my computer (and I do), I don't want to go downloading *another* Python distribution just to get these packages. This worked without a hitch. – Tim Pederick Feb 20 '16 at 09:50
  • 1
    the package [pipwin](https://pypi.org/project/pipwin/) automates this process. `pip install pipwin` followed by `pipwin install numpy` should do it. – RTbecard Jan 03 '20 at 15:21
17

As of March 2016, pip install numpy works on Windows without a Fortran compiler. See here.

pip install scipy still tries to use a compiler.

July 2018: mojoken reports pip install scipy working on Windows without a Fortran compiler.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
leewz
  • 3,201
  • 1
  • 18
  • 38
  • 3
    As of July 2018, pip install scipy is working fine for me on Windows without any Fortran compiler. – mojoken Jul 20 '18 at 18:50
7
py -m pip install numpy

Worked for me!

Vinorth
  • 968
  • 8
  • 13
  • 3
    what about `py -m` makes it work, and what do they do? Please explain your answer! – mix3d Aug 28 '18 at 20:18
  • 1
    'py' is the python command line alias for windows that for one reason or another is sometimes set as a default during python installation. '-m' is mod option which allows you to run a library module as a script. 'py -m' instructs python to run the pip module as a script, passing the install and numpy keywords. – Vinorth Aug 29 '18 at 17:06
  • I would like to add something: For me it works with `py - -m pip install numpy`. Could you edit it? Probably it will help somebody. – TornaxO7 Oct 16 '19 at 15:57
0

First go through page Download Python to download Python 3.6.1 or 2.7.13 either of your choice. I preferred to use Python 2.7 or 3.4.4.

Now after installation, go to the folder name python27 or python34, and click on the script. Now here open the command prompt by left clicking and Run as administrator.

After the command prompt appears, write "pip install numpy" there. This will install the latest version of NumPy and installing it will show a success comment. That's all.

Similarly, Matplotlib can be installed by just typing "pip install matplotlip". And now if you want to download SciPy, then just write "pip install scipy" and if it doesn't work then you need to download Python SciPy from SciPy: Scientific Library for Python and install it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
juzer tarwala
  • 41
  • 1
  • 7
0

Install miniconda (here)

After installed, open Anaconda Prompt (search this in Start Menu)

Write:

pip install numpy

After installed, test:

import numpy as np
-4

I had the same problem.

I decided in a very unexpected way. I just opened the command line as an administrator. And then typed:

pip install numpy
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    pip should (mostly) never be run as Administrator. By doing so, you are ignoring the actual problems, and are causing even more problems you'll find later. – 000 Mar 14 '18 at 21:24