Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing numpy with pip on windows 10 for python 3.7

I installed python 3.7 on my Windows 10 laptop since it has been officially released as of today (06/28/2018). Then i tried to install numpy package using pip

pip install numpy

The install proceeds but finally fails with the below error :

        source = func(extension, build_dir)
      File "numpy\core\setup.py", line 675, in get_mathlib_info
        raise RuntimeError("Broken toolchain: cannot link a simple C program")
    RuntimeError: Broken toolchain: cannot link a simple C program

    ----------------------------------------
Command ""c:\program files\python37\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\pcheg\\AppData\\Local\\Temp\\pip-install-7wjkw5wn\\numpy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\pcheg\AppData\Local\Temp\pip-record-uhj8233f\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\pcheg\AppData\Local\Temp\pip-install-7wjkw5wn\numpy\

Any ideas as to how to overcome this install Error? Thanks.

like image 656
pchegoor Avatar asked Jun 28 '18 15:06

pchegoor


People also ask

Does Python 3.8 support NumPy?

NumPy 1.22. 0 is a big release featuring the work of 153 contributors spread over 609 pull requests. The Python versions supported by this release are 3.8-3.10.


2 Answers

Starting 24 November 2021, latest numpy require at least Python 3.8

Note: This might not be the original question asked, but it might help anyone come here.

To use python 3.7, latest numpy you can use is v1.21.4. So, to install it, use:

pip install numpy==1.21.4

If you write requirements that you hope compatible with python 3.7, you can use numpy<=1.21.4


EDIT: in 20 December 2021, numpy release version 1.21.5 that support Python 3.7

From comment section, by @sam, numpy 1.21.5 support Python 3.7. It was released after 1.22.0rc1 (the latest numpy version as the writing of the original post) that only support Python 3.8++.

Lesson learned from this experience, it would be better to use <,

pip install numpy<1.22.0

or

install_requires = [
    "numpy<1.22.0", # lates version to support python 3.7
],
like image 66
Muhammad Yasirroni Avatar answered Sep 23 '22 17:09

Muhammad Yasirroni


Installing NumPy on Windows is a common problem if you don't have the right build setup. Instead, I always go to Christoph Gohlke's website to download the wheels you can install for your computer. Christoph generously builds the libraries himself with the right build environment and he posts it on his website.


Newer Instructions - For older instructions, please scroll down

First, install pipwin from PyPI which will install a utility that acts like pip but it will download the actual package you're interested in from his website, then use pipwin install to install the package you want.

First do:

pip install pipwin

When that's installed, you can then do:

pipwin install numpy

This will install the latest version of NumPy on your system. This way you don't have to specifically search for the version of NumPy that is for your specific version of Python.


Older instructions

Go to the NumPy section: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy then download the version for 3.7 that is compatible with your version of Python (2 or 3 and 32-bit or 64-bit). For example, the filename numpy‑1.14.5+mkl‑cp37‑cp37m‑win_amd64.whl is for NumPy 1.14.5, Python 3.7 - 64 bit. You can pick out which version of NumPy and which version of the Python interpreter and bit version you need in the filename.

Doing this never requires you to build NumPy yourself or install the required compiler as opposed to installing NumPy through PyPI. You can just download the wheel and install it yourself. Assuming you've already downloaded it, just do:

pip install numpy‑1.14.5+mkl‑cp37‑cp37m‑win_amd64.whl

... assuming the wheel is in the directory you're currently in.

like image 27
rayryeng Avatar answered Sep 24 '22 17:09

rayryeng