在 Windows 8.1、7 Enterprise 和 7 Home Editions 下安装 numpy 期间 pip 的编译器问题 [英] Compiler problems with pip during numpy install under Windows 8.1, 7 Enterprise and 7 Home Editions
问题描述
由于我收到与编译问题相关的各种错误,我无法在运行 Python 3.4 的计算机上通过 pip install numpy 安装 numpy(仅适用于 64 位 Python 安装).
I am unable to install numpy via pip install numpy on my computer running Python 3.4 due to various errors I receive linked to compilation issues (This is only the case on a 64-bit installation of Python).
这是一个被广泛报道的问题,我有 有关无法找到 vcvarsall.bat 的相关问题.我已经在运行 Windows 8.1、7 Enterprise 和 7 Home Edition 的三台不同的干净机器上对此进行了测试,并且它总是出现.
This is a problem that has been reported extensively and I had a related question about unable to find vcvarsall.bat. I have tested this on three different clean machines running Windows 8.1, 7 Enterprise and 7 Home Editions and it always comes up.
安装 Visual Studio 2010 Express C++ 消除了链接中的第一个错误 - 即无法找到 vcvarsall.bat 但抛出下一个以 ValueError 结尾的异常,如下所示:
Installing Visual Studio 2010 Express C++ gets rid of the first error in the link - i.e. Unable to find vcvarsall.bat but throws out a next exception ending with a ValueError as here:
File "C:Python34libdistutilsmsvc9compiler.py", line 371, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:Python34libdistutilsmsvc9compiler.py", line 287, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: ['path']
然后我按照这个建议 并修补了论坛中链接的文件,导致KEY_BASE 错误.
I have then followed this advice and patched the file as linked in the discussion forum which resulted in a KEY_BASE error.
File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommandconfig.py", line 18, in <module>
from numpy.distutils.mingw32ccompiler import generate_manifest
File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilsmingw32ccompiler.py", line 36, in <module>
from distutils.msvccompiler import get_build_version as get_build_msvc_version
File "C:Python34libdistutilsmsvccompiler.py", line 638, in <module>
from distutils.msvc9compiler import MSVCCompiler
File "C:Python34libdistutilsmsvc9compiler.py", line 71, in <module>
r"v%sA"
File "C:Python34libdistutilsmsvc9compiler.py", line 67, in <listcomp>
WINSDK_PATH_KEYS = [KEY_BASE + "Microsoft SDKs\Windows\" + rest for rest in (
NameError: name 'KEY_BASE' is not defined
按照同一链接中的建议,我在 msvc9compiler.py 中调用变量之前添加了以下 KEY_BASE
定义:
Following the advice in the same link, I have added the following definition of KEY_BASE
before the variable gets called in msvc9compiler.py:
KEY_BASE = r"SoftwareMicrosoft\"
导致我无法解决的最终错误:
Which results in the final error I was not able to troubleshoot:
File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommanduild_src.py", line 164, in build_sources
self.build_library_sources(*libname_info)
File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommanduild_src.py", line 299, in build_library_sources
sources = self.generate_sources(sources, (lib_name, build_info))
File "C:UsersMatejAppDataLocalTemppip_build_Matej
umpy
umpydistutilscommanduild_src.py", line 386, in generate_sources
source = func(extension, build_dir)
File "numpycoresetup.py", line 682, in get_mathlib_info
raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
我已经尝试了以下但没有解决Broken toolchain
错误:
I have tried the following but none of it resolved the Broken toolchain
error:
- 此链接,其中包含 msvc9compiler.py 的进一步补丁
- 此 链接 by Peter Cock(此帮助 Python3.4 的 32 位安装)
- 尝试使用
easy_install
进行安装,因为一些用户建议它可能会这样工作
- This link that includes a further patch to msvc9compiler.py
- This link by Peter Cock (This helps on the 32-bit install of Python3.4)
- Tried installing using
easy_install
as some users suggested it might work that way
注意 1:我知道在这个 网站上使用编译的二进制文件的解决方法 如果有的话,我正在专门寻找使用 distutils 的解决方案.注意 2:错误日志明显更大,我将它们剪掉以提高可读性.
NOTE 1: I am aware of the workaround using the compiled binaries on this website I am specifically looking for solution using distutils if there is one. NOTE 2: The error logs are obviously larger and I cut them for readability.
推荐答案
我能够在 Windows 7 Professional(64 位)中重现所有这些错误.
I was able to reproduce all these errors in Windows 7 Professional (64 bit).
您的最终问题(工具链损坏)是由更明显的相关问题引起的.我可以通过更改以下行(在 msvc9compiler.py 中)来解决此问题:
Your final issue (Broken toolchain) is caused by more manifest related issues. I was able to work around this by changing the following line (in msvc9compiler.py):
mfinfo = self.manifest_get_embed_info(target_desc, ld_args)
到
mfinfo = None
从而绕过紧随其后的 if 语句.在此更改后 numpy 为我成功编译.
thus bypassing the if statement which immediately follows. After this change numpy successfully compiled for me.
这篇关于在 Windows 8.1、7 Enterprise 和 7 Home Editions 下安装 numpy 期间 pip 的编译器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!