Installing numpy with pip on windows 10 for python 3.7
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.
pip install numpy on windows 10 showed successful result, but no numpy is in site-package folder
For python 3 you need to use the command 'pip3' instead of 'pip'!!
Additional information:
I think you need to configure your Python to look where your Modules are installed.
Here is where the module might be installed: C:\Users<installUser>\AppData\Local\Programs\Python\Python38\Lib
You may try moving the install to a new path, correcting your 'PATH' variable, and try it again.
To summarize, it could be permissions, could be the install location...
Here is a link to some documentation:
https://realpython.com/lessons/why-cant-python-find-my-modules/
Here is a link to Virtual Environment setups. The doc above mentions this as a possible solution. I use these for Ansible with WSL, and I love them: https://realpython.com/courses/working-python-virtual-environments/
Enjoy!
How to install NumPy using official python IDLE?
You have to install numpy from Command Prompt, not IDLE.
Follow these steps on Windows:
- Press the Windows key on your keyboard.
- Type CMD and open Command Prompt. A black terminal should open up.
- Type 'pip install numpy' and hit enter.
- It should start the installation. After you see the "Successfully Installed" message, go back to your IDLE and try importing numpy, it should work.
NOTE: In case you get a message saying "pip" is not recognized, refer to: https://stackoverflow.com/a/56678271/13699502
Unable to install Numpy
EDIT: Nice it worked for you:
pip3 install numpy
If it, for some reason - for someone in the future wouldn't work in some way:
sudo apt update
sudo apt install python3
sudo apt install pip pip3
sudo apt install python3 python-numpy python3-numpy
pip install numpy
pip3 install numpy
Depending on which version you want.
Hope this can be useful for someone in the future!
Edit2:
Orpheus comment:
pipwin needs to be installed for installing numpy, pip install pipwin
and then pipwin install numpy – Orpheus
Regards.
How to Install Numpy in PyPy on Windows
You don't have any compiler on your system, so PyPy can't compile the packages.
notice the line error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
Download the compiler with default settings and try again.
Installing NumPy on Windows
Some explanations
In the first case, I didn't check but I guess that pip
directly downloads the resource corresponding to the given URL: http://sourceforge.net/projects/numpy/file/NumPy/. The server returns a HTML document, while pip
expects an archive one. So that can't work.
Then there are basically two ways to install Python packages:
- from sources, as you tried then
- from pre-compiled packages
The first case, you tried it with the command pip install numpy
, but since this package contains native code, it requires development tools to be installed properly (which I always found to be a pain in the neck to do on Windows, but I did it so it's clearly feasible). The error you have error: Unable to find vcvarsall.bat
means you don't have the tools installed, or the environment properly set up.
For the second case, you have different kinds of pre-compiled packages:
- wheels, which you install with
pip
as well - installers, which you use as standard installers on Windows
For both, you need to check that the binary has been strictly compiled for your Python architecture (32 or 64 bits) and version.
An easy solution
You can find there several wheels for numpy
: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy. To get the proper architecture, check in the name win32
for 32 bits and amd64
for 64 bits. To get the proper Python version, check cpXX
: first X is major version, and second X is minor version, so for instance cp27
means CPython 2.7.
Example: pip install numpy‑1.9.2rc1+mkl‑cp27‑none‑win32.whl
The hard solution: installing and using development tools
DISCLAIMER: all the following explanations might not be quite clear. They result from several investigations at different moments, but in my configuration they led to a working solution. Some links might be useless, or redundant, but that's what I noted. All of this requires a bit of cleaning, and probably generalization too.
First, you need to understand that disutils
- which is the pre-installed package which handles packages workflow at 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 build the Python machine you installed.
Official distributions of Python use Microsoft Visual C++ for Microsoft Windows packages. So you will need to install this compiler in this case.
How to find proper version of Visual C++
The string printed by Python with this command python -c "import sys; print(sys.version)"
(or when you invoke 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 square brackets is the identification part of the compiler. Unfortunately, this is not quite straightforward, and you have correspondence lists there:
- windows - What version of Visual Studio is Python on my computer compiled with? - Stack Overflow
- visual studio - Detecting compiler versions during compile time - Stack Overflow3
- Pre-defined Compiler Macros / Wiki / Compilers
- WinCvt - Windows Converter toolkit
In the example I gave above, this means Microsoft Visual C++ 2010 64 bits.
How to install Visual C++
You cannot find anymore a standalone package of Visual C++ for modern versions. So you will need to install the Windows SDK itself.
Here are some reference links:
- Download Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 from Official Microsoft Download Center: for Visual C++ 15.00 (Visual Studio 2008). Corresponds to WinSDK 7.
- Download Microsoft Windows SDK for Windows 7 and .NET Framework 4 from Official Microsoft Download Center: for Visual C++ 16.00 (Visual Studio 2010). Corresponds to WinSDK 7.1.
- installation - where can I download the full installer for Visual C++ Express? - Super User
- Visual Studio & co. downloads
Troubleshooting
You might have an error at the installation of the 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.
They have been reported in several questions already:
- Windows 7 SDK Installation Failure
- Error installing Windows 7 SDK 7.1 with VS2008, VS2010 Premium on Win 7 32bit
As a solution, you can check this link: Windows SDK Fails to Install with Return Code 5100
The thing is to remove all conflicting (understand: the ones that the SDK installer tries to install itself) version of the Visual C++ redistributable.
Use development tools
Normally you should run vsvarsall.bat
(located inside the VC
folder of the installation path of Visual Studio - example: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat
) to set up the proper environment variables so that the execution of distutils
doesn't fail when trying to compile a package.
This batch script accepts a parameter, which should set the wanted architecture. However I saw that with the free versions of the SDK some additional scripts were missing when trying several of these parameters.
Just to say that if you are compiling for a 32 bits architecture, simply calling vsvarsall.bat
should work. If you need to compile for 64 bits, you can directly call SetEnv.cmd
, located somewhere under inside the SDK installation path - example: "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
.
How can I install NumPy on Windows using 'pip install'?
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).
Numpy Installation for Python Ver-3.9
The numpy
package does not yet include binaries for Python 3.9, so pip
tries to compile from source. This (of course) requires you to have the appropriate C compiler, as the error message says. That is not straightforward. pip
wants Visual C++ 14.2. The only version readily available from Microsoft is Visual C++ 2019, a.k.a. version 16, which won't work with pip
. You can get Visual C++ 2015, a.k.a version 14, from https://visualstudio.microsoft.com/vs/older-downloads/. But it appears that only the latest version is free. You may have to pay for an older version. Even then, having the compiler isn't enough. You have to configure it, and that is not for the faint-hearted.
Instead, download a prepackaged binary wheel from Christoph Gohlke's site at https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy. The official scipy.org
docs recommend this site. Obviously you must choose the .whl
file that matches your system.
Install the wheel using pip
like this:
pip install D:\Users\<user>\Downloads\numpy-1.19.2+mkl-cp39-cp39-win_amd64.whl
Cannot install latest version of Numpy (1.22.3)
Please check your Python version. Support for Python 3.7 is dropped since Numpy 1.22.0 release. [source]
Related Topics
Efficient Way to Add Spaces Between Characters in a String
Subsampling Every Nth Entry in a Numpy Array
Operationalerror: Database Is Locked
How to Set the Default Color Cycle for All Subplots with Matplotlib
How to Access the Real Value of a Cell Using the Openpyxl Module for Python
Matplotlib: How to Prevent X-Axis Labels from Overlapping
Scraping Ajax Pages Using Python
Why Is Adding Attributes to an Already Instantiated Object Allowed
How to Give Column Name Dynamically from String Variable in SQL Alchemy Filter
Pandas Dataframe Fillna() Only Some Columns in Place
Why Is the Borg Pattern Better Than the Singleton Pattern in Python
Does Tkinter Have a Table Widget
Python SQLite Parameter Substitution with Wildcards in Like
Running an Interactive Command from Within Python
Code for Greatest Common Divisor in Python