简体   繁体   中英

How to fix pip for Python 3.5 not compiling extensions on Windows x64

There are many questions on here about problems with pip installing Python extensions which require C++ compilation. However many of these solutions are out of data as of Python 3.5.

Mostly these problems revolve around the missing vcvarsall.bat problem that comes with not installing Microsoft Visual Studio or not installing the right version.

Having dealt with this issue I am now faced with a value error when I try to install these module through pip.

Can anyone provide a canonical method to get a fresh install of Python 3.5 x64 on a fresh install of Windows (Windows 7 x64 in my case) to be able to correctly install modules through pip that require compilation?

For reference here is the error I am currently getting while attempting to install matplotlib (note the error is being caused by pip attempting to update numpy as it is required by matplotlib)

  vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python34\lib\site-packages\setuptools\msvc9_support.py", line 52,
in query_vcvarsall
    return unpatched['query_vcvarsall'](version, *args, **kwargs)
  File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
ValueError: ['path']

For 3.5 you need Visual C++ 14.0.

Download the Community edition .

cl.exe will be in:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

Installing NumPy and matplotlib with precompiled .whl binaries would avoid this problem entirely.

download: numpy-1.10.1+mkl-cp35-none-win_amd64.whl
from: lfd.uci.edu/~gohlke/pythonlibs/#numpy

and

download: matplotlib-1.5.0rc3-cp35-none-win_amd64.whl
from lfd.uci.edu/~gohlke/pythonlibs/#matplotlib

Installation:

python -m pip install numpy-1.10.1+mkl-cp35-none-win_amd64.whl

python -m pip install matplotlib-1.5.0rc3-cp35-none-win_amd64.whl

another thing I just discovered is that you can do

pip install --only-binary matplotlib

this will avoid having to install 4GB+ of C++ Build Tools or requiring admin rights, and I think it fetches the latest binary available for matplotlib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM