首页 > 解决方案 > python包下载失败

问题描述

我最近在我的 Windows 8 计算机上安装了 python 3。当我尝试从命令行使用 pip 下载 numpy 包时,它不起作用。

这是输出示例:

f:\python\lib\distutils\dist.py:274: UserWarning: Unknown distribution 
option: 'define_macros'
warnings.warn(msg)
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building py_modules sources
building library "npymath" sources
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
error: Could not initialize compiler instance: do you have Visual Studio
installed?  If you are trying to build with MinGW, please use "python setup.py
build -c mingw32" instead.  If you have Visual Studio installed, check it is
correctly installed, and the right version (VS 2008 for python 2.6, 2.7 and 3.2,
VS 2010 for >= 3.3).

原来的例外是:

[WinError 3] The system cannot find the path specified: 'F:\\Visual Studio\\VC\\PlatformSDK\\lib', and the Compiler class was MSVCCompiler

"f:\python\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\MATRIX~1.MAT\\AppData\\Local\\Temp\\pip-install-rxex02t4\\numpy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();

一开始是显示包的下载,似乎下载正确,只是在安装过程中看到一些错误...

标签: pythonwindowsnumpy

解决方案


Numpy 有几个组件需要编译,因此您需要一个 C++ 编译器,例如安装 Visual Studio 的那个:

error: Could not initialize compiler instance: do you have Visual Studio installed?

使用Christoph Gohlke 提供的 Python 扩展包或 Python 发行版(如Windows 上的Anaconda)通常更容易,它会为您提供二进制文件。


推荐阅读