Install NumPy on Windows

I just can't install NumPy on Windows. I keep getting this error -

PS C:\python27> pip install http://sourceforge.net/projects/numpy/file/NumPy/ Collecting http://sourceforge.net/projects/numpy/files/NumPy/ Downloading http://sourceforge.net/projects/numpy/files/NumPy/ (58kB) 100% |################################| 61kB 15kB/s Cannot unpack file c:\users\toshiba\appdata\local\temp\pip-qev4rz-unpack\NumPy (downloaded from c:\users\toshiba\appdata\local\temp\pip-omripn-build, content-type: text/html; charset=utf-8); cannot detect archive format Cannot determine archive format of c:\users\toshiba\appdata\local\temp\pip-omripn-build 

I had a 64-bit version of Python before and was not sure if the version of NumPy is compatible with 64-bit Python. So I uninstalled it and installed the 32-bit version of Python. But still I get the same error. Although my 32-bit version of Python is working fine.

I tried pip install numpy, but in the end I got the following error:

 C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'define_macros' warnings.warn(msg) error: Unable to find vcvarsall.bat ---------------------------------------- Command "C:\Python27\python.exe -c "import setuptools,tokenize;__file__='c:\\users\\toshiba\\appdata\\local\\temp\\pip-build-hdhqex\\numpy\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'),__file__, 'exec'))" install --record c:\users\toshiba\appdata\local\temp\pip-x_6llm-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\toshiba\appdata\local\temp\pip-build-hdhqex\numpy 

Please tell me what I can do wrong.

+6
source share
5 answers

Some explanation

In the first case, I did not check, but I think pip directly loads the resource corresponding to the given URL: http://sourceforge.net/projects/numpy/file/NumPy/ . The server returns an HTML document, and pip expects an archived one. So this will not work.

Then there are two ways to install Python packages:

  • from sources as you tried
  • from precompiled packages

In the first case, you tried it with the pip install numpy command, but since this package contains its own code, it requires the development tools to be installed correctly (which I always thought was a pain in the neck to do on Windows, but I made it so that it it was clear). You have the error error: Unable to find vcvarsall.bat means that you do not have installed tools or an environment that is configured properly.

In the second case, you have different types of precompiled packages:

  • which you install using pip as well
  • which you use as standard installers in Windows

For both, you need to verify that the binary has been strictly compiled for your Python architecture (32 or 64 bits) and version.

Easy solution

You can find several wheels for numpy : http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy . To get the correct architecture, check the name win32 for 32 bits and amd64 for 64 bits. To get the correct version of Python, check cpXX : the first X is the major version, and the second X is the minor version, so, for example, cp27 means CPython 2.7.

Example: pip install numpy‑1.9.2rc1+mkl‑cp27‑none‑win32.whl

Hard decision: installing and using development tools

DISCLAIMER : All of the following explanations may not be entirely clear. They were the result of several studies at different points, but in my configuration they led to a working solution. Some links may be useless or redundant, but this is what I noted. All this requires a little cleaning and, possibly, generalization too.

First, you need to understand that disutils - this is a pre-installed package that processes the package workflow at a lower level than pip (and which is used by the latter) - will try to use a compiler that strictly matches the one that was used to create The Python machine you installed.

Official Python distributions use Microsoft Visual C ++ for Microsoft Windows packages. Therefore, you will need to install this compiler in this case.

How to find the correct version of Visual C ++

A line printed by Python with this python -c "import sys; print(sys.version)" command python -c "import sys; print(sys.version)" (or when invoking the interactive shell) will look like this:

3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)]

The last part between the square brackets is the compiler identification part. Unfortunately, this is not entirely clear, and you have correspondence lists:

In the above example, this means 64 bits of Microsoft Visual C ++ 2010.

How to install Visual C ++

You cannot find the standalone Visual C ++ package for modern versions. Therefore, you will need to install the Windows SDK itself.

Here are some links:

Troubleshooting

You may have an error installing SDK: DDSet_Error: Patch Hooks: Missing required property 'ProductFamily': Setup cannot continue. DDSet_Warning: Setup failed while calling 'getDLLName'. System error: Cannot create a file when that file already exists. DDSet_Error: Patch Hooks: Missing required property 'ProductFamily': Setup cannot continue. DDSet_Warning: Setup failed while calling 'getDLLName'. System error: Cannot create a file when that file already exists.

This has been reported on several issues:

As a solution, you can check this link: Windows SDK could not be installed with return code 5100

The point is to remove all conflicting ones (understand: those that the SDK installer is trying to install on their own), the version distributed in Visual C ++.

Use development tools

Normally, you should run vsvarsall.bat (located inside the VC folder of the Visual Studio installation path - example: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat ) to configure the correct environment variables so that distutils do not failed when trying to compile a package.

This batch script takes a parameter that should set the required architecture. However, I saw that with the free versions of the SDK, some additional scripts were missing when trying to execute several of these parameters.

Just to say that if you are compiling a 32-bit architecture, you just need to call vsvarsall.bat . If you need to compile 64 bits, you can directly call SetEnv.cmd , located somewhere inside the SDK installation path, for example: "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 .

+20
source

On Windows, pip great for installing packages that don't require compilation. Otherwise, seriously, get rid of the hassle of building and maintaining packages and take advantage of the work that others have done for you. I recommend using any of these Python distributions:

Anaconda is a bit more to download and install, but by default it includes many useful third-party packages (e.g. numpy). ActivePython includes a package manager that makes it easy to install precompiled binaries (installing numpy is as easy as pypm install numpy ).

The advantage of using these Python distributions is that you can quickly start a working installation in minutes.

+2
source

The best solution for this is to download and install VCforPython2.7 from https://www.microsoft.com/en-us/download/details.aspx?id=44266

Then try the install numpy command.

100% working

+1
source

I tried installing numpy for Windows 7, 64-bit and spent quite a lot of time. I actually tried to configure sklearn. Investigated a lot of posts, documented what worked for me. Hope this saves you some time! https://simplemachinelearning.wordpress.com/2015/11/09/set-up-sklearn-on-windows/

0
source

I also ran into the above problem when setting up python for machine learning.

I have completed the following steps: -

Install python-2.7.13.msi

• set PATH = C: \ Python27

• set PATH = C: \ Python27 \ Scripts

Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy

Downloads: - • numpy-1.13.1 + mkl-cp27-cp27m-win32.whl • scipy-0.18.0-cp27-cp27m-win32.whl

Numpy installation: pip install numpy-1.13.1 + mkl-cp27-cp27m-win32.whl

Install scipy: pip install scipy-0.18.0-cp27-cp27m-win32.whl

You can check the correctness using below cmds: -

 >>> import numpy >>> import scipy >>> import sklearn >>> numpy.version.version '1.13.1' >>> scipy.version.version '0.19.1' >>> 
0
source

Source: https://habr.com/ru/post/982212/


All Articles