为Python 2.7构建/安装C模块时出错
我想尝试安装/编译python的python(版本信息)时出现以下错误:
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:22:14) [MSC v.1500 64 bit (AMD64)] on win32
错误:
building 'deap.cTools' extension
Traceback (most recent call last):
File "setup.py", line 40, in <module>
cmdclass = {'build_py': build_py}
File "C:Python27libdistutilscore.py", line 152, in setup
dist.run_commands()
File "C:Python27libdistutilsdist.py", line 953, in run_commands
self.run_command(cmd)
File "C:Python27libdistutilsdist.py", line 972, in run_command
cmd_obj.run()
File "C:Python27libdistutilscommandinstall.py", line 563, in run
self.run_command('build')
File "C:Python27libdistutilscmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:Python27libdistutilsdist.py", line 972, in run_command
cmd_obj.run()
File "C:Python27libdistutilscommandbuild.py", line 127, in run
self.run_command(cmd_name)
File "C:Python27libdistutilscmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:Python27libdistutilsdist.py", line 972, in run_command
cmd_obj.run()
File "C:Python27libdistutilscommandbuild_ext.py", line 340, in run
self.build_extensions()
File "C:Python27libdistutilscommandbuild_ext.py", line 449, in build_extensions
self.build_extension(ext)
File "C:Python27libdistutilscommandbuild_ext.py", line 499, in build_extension
depends=ext.depends)
File "C:Python27libdistutilsmsvc9compiler.py", line 473, in compile
self.initialize()
File "C:Python27libdistutilsmsvc9compiler.py", line 383, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:Python27libdistutilsmsvc9compiler.py", line 299, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
按照这里的建议安装了PyWin,但它没有帮助。 我很感谢帮助解决这个问题。
编辑
尝试安装scikit-learn
时出现同样的问题
File "C:Python27libdistutilsmsvc9compiler.py", line 299, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: [u'path']
我在我的博客上面总结了上面。 http://springflex.blogspot.com/2014/02/how-to-fix-valueerror-when-trying-to.html
使用所有必需的组件安装Visual Studio 2008速成版:
安装Microsoft Visual Studio 2008速成版。 主Visual Studio 2008 Express安装程序可从(C ++安装程序名称为vcsetup.exe)中获取:
安装Microsoft Windows SDK。 Microsoft Windows SDK可通过搜索Microsoft的下载站点或直接访问:http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en
要验证是否已安装了所有组件,请检查Microsoft SDK是否包含C / C ++编译器“cl.exe”的“amd64”版本。 这通常安装到
C:Program Files (x86)Microsoft Visual Studio 9.0VCbinamd64cl.exe
将... / VC / bin / vcvars64.bat复制到... / VC / bin / vcvarsamd64.bat
将... / VC / bin / vcvars64.bat复制到... / VC / bin / amd64 / vcvarsamd64.bat
由于您使用的是64位版本的Python,因此一旦安装了适用于Windows 7和.NET Framework 3.5 SP1的Microsoft Windows SDK(其安装了安装Visual Studio 2008 SP1 Express Edition时未安装的64位编译器); 您需要将vcvars64.bat
复制到vcvarsall.bat
声称它的位置。
从%CSIDL_PROGRAM_FILESX86%Microsoft Visual Studio 9.0VCbin
,您需要将vcvars64.bat
复制到amd64vcvarsamd64.bat
。
注意目标文件名中的amd部分。
微软现在发布了一个适用于Python 2.7的Visual C ++编译器,但它可以用于使用相同编译器的其他Python版本。 检查系统要求:需要setuptools 6.0或更高版本。 它不适用于使用distutils的软件包。
链接地址: http://www.djcxy.com/p/26297.html上一篇: Errors while building/installing C module for Python 2.7
下一篇: Can I install Python windows packages into virtualenvs?