12

我在尝试为 python 安装/编译ctools时遇到以下错误(版本信息)

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
  • 操作系统:Windows 7 Professional 64 位(Service Pack 1)
  • 已安装:Microsoft Visual C++ 2008 速成版

错误:

building 'deap.cTools' extension
Traceback (most recent call last):
  File "setup.py", line 40, in <module>
    cmdclass = {'build_py': build_py}
  File "C:\Python27\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\install.py", line 563, in run
    self.run_command('build')
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 340, in run
    self.build_extensions()
  File "C:\Python27\lib\distutils\command\build_ext.py", line 449, in build_extensions
    self.build_extension(ext)
  File "C:\Python27\lib\distutils\command\build_ext.py", line 499, in build_extension
    depends=ext.depends)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile
    self.initialize()
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize
    vc_env = query_vcvarsall(VERSION, plat_spec)
  File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
ValueError: [u'path']

我已经按照此处的建议安装了 PyWin ,但没有帮助。我很感激帮助解决这个问题。

编辑

尝试安装时出现同样的问题scikit-learn

  File "C:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsall
    raise ValueError(str(list(result.keys())))
ValueError: [u'path']
4

5 回答 5

21

我在我的博客中总结了以上内容。 http://springflex.blogspot.com/2014/02/how-to-fix-valueerror-when-trying-to.html

要安装包含所有必需组件的 Visual Studio 2008 Express Edition:

  1. 安装 Microsoft Visual Studio 2008 速成版。主要的 Visual Studio 2008 Express 安装程序可从(C++ 安装程序名称为 vcsetup.exe)获得:

  2. 安装 Microsoft Windows SDK。Microsoft Windows SDK 可通过搜索 Microsoft 的下载站点获得,或直接访问: http ://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en

  3. 要验证您是否已安装所有组件,请检查 Microsoft SDK 是否包含 C/C++ 编译器“cl.exe”的“amd64”版本。这通常安装在

    C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\cl.exe
    
  4. 复制 .../VC/bin/vcvars64.bat 到 .../VC/bin/vcvarsamd64.bat

  5. 将 .../VC/bin/vcvars64.bat 复制到 .../VC/bin/amd64/vcvarsamd64.bat

于 2014-02-20T05:03:47.393 回答
18

由于您使用的是 64 位版本的 Python,一旦您安装了Microsoft Windows SDK for Windows 7 和 .NET Framework 3.5 SP1 (它安装了安装Visual Studio 2008 SP1 Express Edition 时未安装的 64 位编译器);您需要将 复制到声称vcvars64.bat的位置。vcvarsall.bat

%CSIDL_PROGRAM_FILESX86%\Microsoft Visual Studio 9.0\VC\bin\,您需要复制 vcvars64.batamd64\vcvarsamd64.bat

注意目标文件名中的amd部分。

于 2013-11-11T20:45:56.387 回答
1

Microsoft now publishes a Visual C++ compiler just for Python 2.7, although it will work for other versions of Python that used the same compiler. Check the system requirements: setuptools 6.0 or later is required. It will not work with packages using distutils.

于 2015-08-07T21:39:06.130 回答
0

我遇到了这个问题,因为我没有 64 位版本的 Visual C++ 2008。为了解决这个问题,我按照这个答案通过程序和功能中的更改/删除安装了它。

于 2014-05-03T03:00:27.030 回答
0

我遇到了同样的问题,但只是重命名上面列出的文件(以某种不透明的方式)对我不起作用。起作用的是一个更简单的解决方案。只需在开始安装之前运行 vcvarsall.bat。这设置了正确的路径并且更容易理解。就我而言,我需要一个 64 位版本,所以我运行:“C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat”x64

于 2015-12-07T18:35:20.383 回答