PyCrypto install error on Windows - python

I am trying to install PyCrypto 2.6 Library on my computer. But I keep getting the following error
D:\Software\Python\package\pycrypto-2.6>python setup.py build
running build
running build_py
running build_ext
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
building 'Crypto.Random.OSRNG.winrandom' extension
error: Unable to find vcvarsall.bat
My System has
Windows 8 Pro 64-bit, Visual Studio Enterprise 2012 and Python 3.3
To fix the error I tried to set the Environment Variable VS90COMNTOOLS=%VS110COMNTOOLS% as advised by fmuecke in the post error: Unable to find vcvarsall.bat but it didn't work for me.
Can any one please advise me how to fix this error.
FYI, I don't to install VC2008 etc..

I managed to install PyCrypto 2.6 by using the prebuilt binary for Python3.3 from The Voidspace Python Modules.
It doesn't actually fix the error: Unable to find vcvarsall.bat for other package which don't have a prebuilt binaries available.
However it eliminates the need to build PyCrypto package, allowing me to install PyCrypto on my system without getting the error.

I've just used
https://www.microsoft.com/en-gb/download/details.aspx?id=44266
with setuptools > 6.0 and run
'pip install pycrypto'
and it worked

I know this is an old question, but I also need today much time to get paramiko wokring.
I want to use Python 3.4 and on voidspace, there are no prebuild binaries for 3.4.
Finally, I got a wokring pycrypto by installing "Microsoft Studio Express 2010 C++" and run from the pycrypto 2.7 folder:
python setup.py build --compiler msvc
python setup.py install
python setup.py bdist_wininst
All the "tricks" with enviroment variables doesn't work for me.
If it helps somebody, all the thanks goes to:
http://flintux.wordpress.com/2014/04/30/pycrypto-for-python-3-4-on-windows-7-64bit/

For Python 3.5 you can do this:
Install a PyCrypto binary from this site :
https://github.com/sfbahr/PyCrypto-Wheels
The best way to do it, is:
64bits Python
c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win_amd64.whl pycrypto
32bits Python
c:\Python35\Scripts\pip.exe install --use-wheel --no-index --find-links=https://github.com/sfbahr/PyCrypto-Wheels/raw/master/pycrypto-2.6.1-cp35-none-win32.whl pycrypto
Of course replace c:\Python35\Scripts\pip.exe by your python pip path
To know your python version, run python and look at the architecture displayed between brackets:
C:\Users\utilisateur>python
Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Hope this can help.

You may install mingw64 and then run from the PyCrypto unzipped files directory:
python setup.py build --compiler=mingw32

Updated answer for 2021 (many other answers are outdated)
Python 2.7 is EOL (end-of-life), and Microsoft has removed the download link for the Visual C++ 8.0 compiler, which was needed for compiling native Python 2.7 modules (and which they later called something like "C++ compiler for Python 2.7", VCForPython27.msi). Therefore pip install pycrypto no longer works.
To see for yourserlf, check out this answer with a now defunct download link. Don't search for VCForPython27 on GitHub - you will find projects, but they are not official Microsoft projects, so you may want to stay away from those.
If you find yourself in this situation, then seriously, it's high time to migrate to Python 3. Don't download old builds of PyCrypto or Visual C++ 8.0 from random websites or from web archive links, especially not since this is a library for cryptography that should be kept up to date.

I am using Windows 10 - All I needed to do was update my system with Visual C++ Build Tools 2015 which I found on this page: https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/
About mid-page, you will see some download options - choose your python version and download the correct package
I then re-imported the program I was trying to install and NO more error! Woohoo!

if you are
VS 2010
SET VS90COMNTOOLS=%VS100COMNTOOLS%
VS 2012
SET VS90COMNTOOLS=%VS110COMNTOOLS%
VS 2013
SET VS90COMNTOOLS=%VS120COMNTOOLS%
and then
python setup.py install

Related

Installing wxPython on Windows: DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required

I have installed:
Python 3.10.1
PyCharm Community 2021.3
Visual Studio Build Tools 2022, including:
C++ Build Tools Core Features
C++ 2022 Redistributable Update
C++ core desktop features
MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
Windows 10 SDK (10.0.19041.0)
C++ CMake tools for Windows
Testing tools core features - Build Tools
C++ AddressSanitizer
C++/CLI support for v143 build tools (Latest)
C++ Modules for v143 build tools (x64/x86 - experimental)
When trying to install wxPython in my project's virtualenv, I get this error:
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Both the error and anything I can find on the internet (including here) tells me to download C++ build tools and install C++ 14.2 or greater / the latest version. I have:
done that (see the list above),
rebooted
venv/Scripts/pip install --upgrade setuptools
venv/Scripts/pip install --upgrade wheel
venv/Scripts/pip install --upgrade pip
What am I missing here? Is there some sort of path variable that I need to configure somewhere so pip/wheel/setuptools knows where to find the compiler?
I have the same problem. Solved for me to use Python 3.9.9.
Its maybe about a distutils problem in Python 3.10.1 with this warning from msvc9compiler.py:
DeprecationWarning: The distutils package is deprecated and slated for
removal in Python 3.12
This leads to:
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
The current wxPython 4.1.1 is not compatible with python 3.10 on windows (it works on Linux). You can download an older version of Visual Studio Build Tools to get around the issue with the DistutilsPlatformError, however you will not be able to successfully install on python 3.10 on windows. I found a solution for the problem, the link is Compile_wxPython_4.1.2a1_Python3.10_Windows. I was not able to compile it but there is a link to the whl file that was bult using the procedure. I downloaded and installed it using the command pip install wxPython-4.1.2a1-cp310-cp310-win_amd64.whl
I am confident in the near future 4.1.2 will be released to PyPy and you will be able to install it using pip.
The answers here have already provided the right pointers, but in this anser I would like to list all the necessary steps directly so you don't have to visit other resources, and it also provides the solution for both 64-bit and 32-bit versions of Python 3.10.x.
Solution for 64-bit version of Python 3.10.x
Download the wxPython wheel file directly here: wxPython-4.1.2a1-cp310-cp310-win_amd64.whl.
Using the Windows command line, move to the folder where you downloaded the wheel file.
Run: pip install wxPython-4.1.2a1-cp310-cp310-win_amd64.whl
Solution for 32-bit version of Python 3.10.x
Prerequisites
Download and install Microsoft C++ Build Tools.
Download and install cygwin.
Download and install GitHub Command Line Interface (GitHub CLI).
Build wxPython
In the Windows command line ran as Administrator, execute the following commands:
gh repo clone wxWidgets/Phoenix
cd .\Phoenix\
git submodule update --init --recursive
python -m venv venv
.\venv\Scripts\activate
pip install -r .\requirements.txt
python build.py dox etg --nodoc sip build
Create wheel
Still in the command line, execute the following:
python setup.py bdist_wheel
Install wheel
Still in the command line, execute the following:
cd dist
pip install <created-wheel-filename>
The <created-wheel-filename> should be the wheel you just created, so something like: wxPython-4.2.0a1-cp310-cp310-win32.whl
Source
Compile wxPython 4.1.2a1 using Microsoft C++ Build Tools 2019
This problem is currently being fixed. Or rather it is fixed and a PR will be made with the fix pretty soon. I wrote a proper MSVC build environment script instead of the one that comes with either distutils or setuptool neither of which really work correctly when setting up an MSVC build environment.
Here is a link to the script I wrote that handles setting up the build environment properly
https://github.com/kdschlosser/python_msvc
and here is a link to a working fork of wxPython
https://github.com/oleksis/Phoenix/tree/try-pyMSVC
The problem with wxPython compiling properly is because neither setuptools or distutils has the capability of detecting Visual Studio 2022 properly. My script uses COM interfaces to collect the information needed to set up the build environment. The environment is set up without using the vcvar*.bat files.

How to fix" ERROR: Failed building wheel for fa2"? [duplicate]

I am on a windows 10 machine and recently moved from python 2.7 to 3.5. When trying to install lxml through pip, it stops and throws this error message-
building 'lxml.etree' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
I have a working copy of VS 2015 installed. When I try to install the visual cpp tools through that link, it says that Microsoft Visual Studio 2015 is already installed on the machine. I also tried installing visual studio c++ 2015 redistributables, both 64 and 32 bit versions, but both of them say that there's another version of the product already installed.
typing set in the command prompt includes this -
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
Which means that the path is set.
This is probably the only resource I could find on SO, but the answer suggests rolling back to Python 3.4.3 from 3.5. Has anybody resolved problems of this kind?
Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)
EDIT: I managed to install it using the precompiled binary (Thanks Paul), but I would still like to know what's causing this.
Have you checked that when you installed Visual Studio, you installed the C++ compiler? It seems like a silly question, but this is the mistake I made. Check by going into the setup for visual studio (Programs and features: Modify "Visual Studio 2015"), then under Programming Languages->VC++, make sure it's ticked.
Run pip install wheel
Download lxml from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml, if your python version is 3.5 , download lxml-3.6.4-cp35-cp35m-win32.whl.
Run python -m pip install lxml-3.6.4-cp35-cp35m-win32.whl
As an update to the answer from #davidsheldon above, if you want to use Visual Studio Build Tools 2017 instead of 2015, it will work.
I found that the default install of the build tools stand alone was not enough, however, I added `VC++ 2015.3 ... toolset for desktop (x86,x64) and then python was happy:
I've found another solution to get through this:
Because I use anaconda python, so I use this code:
conda install -c conda-forge scrapy
I have same question with you! I found a way no need install vs2015,maybe,you just haven't install twisted.http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted .download twisted --version(Twisted‑17.5.0‑cp36‑cp36m‑win_amd64.whl)(maybe win_amd32.whl if 64didn't work),and run : pip PATH + filename
pip install C:\Users\CR\Downloads\Twisted-17.5.0-cp36-cp36m-win_amd64.whl
pip install Scrapy
I just install successful! good luck for you!
my step to insatll scrapy:
1.pip install wheel
2.pip install lxml
3.pip install pyOpenSSL
4.pip install Twisted (fault->do like above)
5.install pywin32 form : https://sourceforge.net/projects/pywin32/files/pywin32/Build%20220/
6.pip Scrapy (succesful)
Had the same problem and noticed that I had installed the 32bit version in a 64bit machine. All I did was uninstall the wrong one and install the right version and it worked fine.
Easiest way to achieve this, can be automated as it doesn't require user input:
python -m pip install https://download.lfd.uci.edu/pythonlibs/archived/lxml-4.9.0-cp311-cp311-win_amd64.whl
This will install the 64-bit version on your machine.
First:
pip install wheel
Second: go to http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
and download proper wheel.
pip install the file you downloaded (.whl).

pip install error: Microsoft Visual C++ 10.0 is required

I have Python 3.4, running on Windows 10 x64, trying to install pylint via pip: pip install pylint.
When doing so, I get the following error: Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.microsoft.com/download/details.aspx?id=8279
However I already have:
Microsoft Visual C++ 2010 x64, Microsoft Visual C++ x86 both Redistributable
Microsoft Visual C++ 2013 x64, Microsoft Visual C++ x86 both Redistributable
Microsoft Visual C++ 2015 - 2019 x64, Redistributable
Microsoft Visual C++ 2017 x64, Microsoft Visual C++ 2017 x86 both Redistributable
I saw some other posts with possible solutions that I've tried and did not seem to help to me -
updating setuptools and virtualenv
Downloading the SDK given in the error
Add VS110COMNTOOLS, VS120COMNTOOLS, VS140COMNTOOLS env variables
Of course, after every attempt I've rebooted my PC.
What else could I try to fix this?
Is it possible to install pylint without pip?
You don't have any Visual C++, you only have Redistributable packages. They install run-time libraries that are used to run applications written with VC. But you need Visual C++ compiler! Install Visual Studio 2010 Express.
See also https://stackoverflow.com/search?q=%5Bpip%5D+%22Microsoft+Visual+C%2B%2B+10.0+is+required%22
Python 3.4
According to [Python]: PEP 429 -- Python 3.4 Release Schedule (emphasis is mine):
Python 3.4 has now reached its end-of-life and has been retired. No more releases will be made.
The last version (3.4.10) was released on 2019/03/18.
So, you should move away from it (I'd recommend the (current) LTS version: 3.7). That doesn't magically solve all possible problems, but being a newer version, it requires newer build tools (VStudio) which are easier to find, and have a higher probability of installing and running correctly.
Notes:
Even if you manage to solve the problem for this version, you'll be likely to run into it again when trying to install other such packages, as more and more of them will no longer support it
Python 3.5+ are built with VStudio 14.X. Starting with VStudio 2015 (14.0), MS did some changes to improve backward and forward compatibility between VStudio versions. More details on [SO]: How to circumvent Windows Universal CRT headers dependency on vcruntime.h - (#CristiFati's answer)
2. Pylint
[PyPI]: Pylint is written entirely in Python (I checked the source code), so it wouldn't require a C(++) compiler. This is also backed up by the existence of the pylint-2.3.1-py3-none-any.whl file (available for download).
Some of its dependencies (wrapt, typed-ast: which don't have prebuilt binaries for Python 3.4 on Win - makes sense considering the previous bullet) require it.
According to [PyPA]: pip install - Options (pip install -h):
--no-deps
    Don’t install package dependencies.
Now, I don't know your Pylint usecase: whether you are using the parts of it that require the above dependencies, but if you don't, simply pass the --no-deps argument.
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q057581571]> sopr.bat
*** Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ***
[prompt]> "e:\Work\Dev\VEnvs\py_064_03.04.04_test0\Scripts\python.exe" -c "import sys;print(sys.version)"
3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[prompt]> "e:\Work\Dev\VEnvs\py_064_03.04.04_test0\Scripts\python.exe" -m pip freeze
[prompt]> "e:\Work\Dev\VEnvs\py_064_03.04.04_test0\Scripts\python.exe" -m pip install --no-deps pylint
Collecting pylint
Using cached https://files.pythonhosted.org/packages/60/c2/b3f73f4ac008bef6e75bca4992f3963b3f85942e0277237721ef1c151f0d/pylint-2.3.1-py3-none-any.whl
Installing collected packages: pylint
Successfully installed pylint-2.3.1
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
[prompt]> "e:\Work\Dev\VEnvs\py_064_03.04.04_test0\Scripts\python.exe" -m pip freeze
pylint==2.3.1
[prompt]>
[prompt]> :: Pylint dummy usage example - just import it
[prompt]> "e:\Work\Dev\VEnvs\py_064_03.04.04_test0\Scripts\python.exe" -c "import pylint;print(pylint)"
<module 'pylint' from 'e:\\Work\\Dev\\VEnvs\\py_064_03.04.04_test0\\lib\\site-packages\\pylint\\__init__.py'>
As seen, the package was installed, and it's usable.
Notes:
There are (official) prebuilt Python 3.5 (and newer) binaries for typed-ast, but not for wrapt, so a Python upgrade will still require building it (assuming that it's needed)
You could always turn to unofficial prebuilt binaries. [UCI.LFD]: Unofficial Windows Binaries for Python Extension Packages is the most comprehensive repository (that I know of), and contains the wrapt build for Python 3.4 (but doesn't the typed-ast one :) )
3. Or else ...
Python 3.4 version is built (on Win) using VStudio 2010 (10.0). Since it's written in C, it requires a C compiler. More details on [Python.Wiki]: WindowsCompilers.
Every package that contains parts written in C(++) (and needs to be built from sources at pip install time - meaning that there are no prebuilt binaries on the public repository), also requires the compiler (the compiler version must match the one that Python was built with).
The above URL lists the 4 items that need to be installed in order to get things going:
Microsoft Visual C++ 2010 Service Pack 1 Compiler Update for the Windows SDK 7.1
Microsoft Windows SDK for Windows 7 and .NET Framework 4
The other 2 are dependencies for these 2 (and I tend to think that will be automatically installed)
I didn't (have to) attempt this step, as I already have VStudio 2010 installed. As a side note, I have 7 VStudio versions (with their corresponding SDKs) installed, and also I have 30+ Python instances (installed, VEnvs, custom built by me, installed by other 3rd-party software, ...) on my machine.
Once you get the (above) build tools installed (and the %VS*% env vars pointing to the desired VStudio version - you have to do this manually when having multiple versions), you will be able to install most of the Python packages containing C(++) code. But there will probably be a few exceptions. Here's an example that gave me some headaches: [SO]: Installing pygraphviz on Windows 10 64-bit, Python 3.6 - (#CristiFati's answer) (check it out - and the URLs it references, there's a bunch of useful information there).
I noticed that you're having some problems installing VStudio 2010. With the risk of repeating myself, switching to a newer Python version would make some of your current problems go away, since it would require newer build tools which are less likely to fail installing. Everything else still applies, though.
Update #0
Concerning the last inquiry in the question:
It's possible to install Pylint without pip, for example doing (almost) what pip does, but manually. However, from what am I concerned, this would be a (lame) workaround (gainarie). Anyway, here are the steps:
Download and unpack the .whl (from section #2.)
Copy the (inside) pylint dir, under Python's site-packages dir
But again, everything done here is also done properly in #2., so this is truly pointless.
Maybe you can try to install pylint from https://www.lfd.uci.edu/~gohlke/pythonlibs/
You could try installing Visual Studio Code and opening your project from there. From my experience, Visual Studio Code offers to install pylint (and other missing libraries) for you when it recognizes it's missing.

Trouble installing and importing pyHook

This is my first question on this site so I hope I format this correctly. I also am very new to programming so bear with my lack of knowledge, thank you!
I'm trying to install pyHook like so and I keep getting this error message:
C:\Python27>py -2.7 -m pip install pyHook-1.5.1-cp27-cp27M-win_amd64.whl
pyHook-1.5.1-cp27-cp27M-win_amd64.whl is not a supported wheel on this platform.
I have python 2.7.14 as you can see from below:
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:25:58) [MSC v.1500 64 bit
(AMD64)] on win32
Just in case, I tried updating pip and It said it was up to date. I also tried install this version of the .whl and I get the same error:
C:\Python27>py -2.7 -m pip install pyHook-1.5.1-cp27-cp27m-win32.whl
pyHook-1.5.1-cp27-cp27m-win32.whl is not a supported wheel on this platform.
From reading online I believe cp27 indicates its for python 2.7 and to be safe I tried the 64 bit and 32 bit files, but nothing seems to work. If anyone could offer up any solutions or advice, it would be greatly appreciated!
I installed Python 2.7, then pyHook and was able to get it working following these exact steps.
Note, I was using Anaconda to create the Python 2.7 environment and Windows 10 is my OS.
conda create -n python27 python=2.7 This created a new conda environment with python 2.7.14.
activate python27
python -m pip install --upgrade pip This installed pip version 10.0.0
Downloaded pyHook from the unofficial windows binaries.
Specifically: pyHook-1.5.1-cp27-cp27m-win_amd64.whl
Navigated to downloads folder in command prompt
pip install pyHook-1.5.1-cp27-cp27m-win_amd64.whl
That installed it properly with no error messages. Hope that helps. My guess is that the new pip version fixes it, or there is a problem with how you are installing Python 2.7, so try Anaconda (or miniconda if you want to keep it light)
I was also able to import it with no problem after these steps.
Many binaries depend on numpy-1.13+mkl and the Microsoft Visual C++ 2008 (x64, x86, and SP1 for CPython 2.7), Visual C++ 2010 (x64, x86, for CPython 3.4), or the Visual C++ 2017 (x64 or x86 for CPython 3.5, 3.6, and 3.7) redistributable packages.
Install numpy+mkl before other packages that depend on it.
I have Microsoft Visual C++ 2008.I just do this,
python -m pip install numpy-1.13.3+mkl-cp27-cp27m-win_amd64.whl
python -m pip install pyHook-1.5.1-cp27-cp27m-win_amd64.whl
then it work.

Installing NumPy on Windows

I'm simply unable to 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 Python 64 bit version earlier and I was not sure if NumPy version was compatible with 64-bit Python. So I uninstalled it and installed a 32-bit Python version. But still I'm getting the same error. Though my Python 32-bit version is working fine.
I tried "pip install numpy", but that gave me the following error at the end -
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
What might I be doing wrong?
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.
On Windows, pip is great for installing packages that do not require compiling. Otherwise, seriously, save yourself the hassle of building and maintaining packages, and take advantage of the work others did for you. I recommend using either of these Python distributions:
ActivePython
Anaconda
Anaconda is a little larger to download and install, but it includes many useful third-party packages by default (such as numpy). ActivePython includes a package manager which allows you to easily install pre-compiled binaries (installing numpy is as easy as pypm install numpy).
The advantage of using these Python distributions is that you can get a working installation running in minutes, in an easily reproducible manner.
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 pip install numpy.
100% working
I tried to install numpy for windows 7, 64-bit and spent quite sometime. I was actually trying to setup sklearn. Researched many posts, documented what worked for me. Hope it saves your time!
https://simplemachinelearning.wordpress.com/2015/11/09/set-up-sklearn-on-windows/
I too faced the above problem while setting up python for machine learning.
I followed the below 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
Downloaded:- • numpy-1.13.1+mkl-cp27-cp27m-win32.whl
• scipy-0.18.0-cp27-cp27m-win32.whl
Installing numpy:
pip install numpy-1.13.1+mkl-cp27-cp27m-win32.whl
Installing scipy:
pip install scipy-0.18.0-cp27-cp27m-win32.whl
You can test the correctness using below cmds:-
>>> import numpy
>>> import scipy
>>> import sklearn
>>> numpy.version.version
'1.13.1'
>>> scipy.version.version
'0.19.1'
>>>

Categories

Resources