python - 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();
一开始是显示包的下载,似乎下载正确,只是在安装过程中看到一些错误...
解决方案
Numpy 有几个组件需要编译,因此您需要一个 C++ 编译器,例如安装 Visual Studio 的那个:
error: Could not initialize compiler instance: do you have Visual Studio installed?
使用Christoph Gohlke 提供的 Python 扩展包或 Python 发行版(如Windows 上的Anaconda)通常更容易,它会为您提供二进制文件。
推荐阅读
- html - 将文本分段为单行并仅显示最后一个字符
- android - 如何减少谷歌地图 v2 移动数据使用量?
- listview - JavaFx ListView 中的索引 OutOfBoundExceptionException
- javascript - 需要使用正则表达式匹配排除 1M 记录,以获得具有最佳算法的代码流
- django - 如何检查 Flask 中修改了表单的哪些字段?
- mysql - vb.net 缓存数据库表
- java - 创建名为“webSecurityConfig”的 bean 时出错,因为当我尝试将其自动装配到 WebSecurityConfig 时,UserService Bean 不存在
- javascript - 如何从选定的li中获取文本值并使用js将其传递给另一个li中的输入
- spring - 在 1.4.5 中升级到 Spring Boot 2.1.3 后阅读文档时如何让 @TypeAlias 工作
- log4j - 如何在 log4j 属性文件中获取上下文路径?