Python 2.7.7 包安装给出 Visual C++ cl.exe 错误 : command failed with exit status 2

标签 python windows python-2.7 visual-c++

Python 2.7.7 在安装包时出现 Visual C++ 问题。我收到以下错误:

error: Setup script exited with error: command 'C:\\Program Files\\Common Files\
    \Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status
     2*
  1. 我使用的是 Windows Vista、Python 2.7.7
  2. 我使用“setup.py install”通过 Windows cmd 终端安装了该软件包
  3. 我已经安装了“Microsoft Visual C++ Compiler for Python 2.7”,并确保路径“C:\Program Files\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe”包含“cl. exe”
  4. 根据建议here 。我已检查我的 Visual C++ 版本是否与我的 Python 版本兼容。 (我在“C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Visual C++ Compiler Package for Python 2.7”处有一个“Visual C++ 2008 32位命令提示符”快捷方式。2008版本是我的正确版本。 python 版本。(均为 MSC v.1500。)
  5. 我已将 python setuptools 更新到 setuptools 17.1.1

以下是发生错误之前的安装过程记录:

Searching for python-axolotl-curve25519
Reading https://pypi.python.org/simple/python-axolotl-curve25519/
Best match: python-axolotl-curve25519 0.1
Downloading https://pypi.python.org/packages/source/p/python-axolotl-curve25519/
python-axolotl-curve25519-0.1.tar.gz#md5=f28d902df9044f0bf86a35a4bd2ec092
Processing python-axolotl-curve25519-0.1.tar.gz
Writing c:\users\eg\appdata\local\temp\easy_install-l68mxp\python-axolotl-curve2
5519-0.1\setup.cfg
Running python-axolotl-curve25519-0.1\setup.py -q bdist_egg --dist-dir c:\users\
eg\appdata\local\temp\easy_install-l68mxp\python-axolotl-curve25519-0.1\egg-dist
-tmp-hvxf2n
curve25519module.c
curve25519module.c(76) : error C2143: syntax error : missing ';' before 'type'
curve25519module.c(78) : error C2065: 'result' : undeclared identifier
curve25519module.c(82) : error C2143: syntax error : missing '{' before '*'
curve25519module.c(100) : warning C4133: 'return' : incompatible types - from 'P
yObject *' to 'int *'
curve25519module.c(146) : warning C4133: 'initializing' : incompatible types - f
rom 'int *(__cdecl *)(PyObject *,PyObject *)' to 'PyCFunction'
**error: Setup script exited with error: command 'C:\\Program Files\\Common Files\
\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status
 2**

我对此很陌生,不知道还能尝试什么。将不胜感激任何帮助。提前致谢。

最佳答案

在 Windows 10 上安装 pycocotools 时遇到此问题。Python 2.7 不支持编译 C99 代码所需的 Visual C++ 14。这就是编译错误(C2065、C4133 等)的原因。

我能够通过以下方式解决这个问题:

  1. 安装 Visual Studio 2015 构建工具(这将安装 C++ 14 编译器)。
  2. 安装新版本的 Python(推荐 3.6)

有关 Python 的 Windows 编译器的更多信息 here 。另请检查此post

enter image description here

关于Python 2.7.7 包安装给出 Visual C++ cl.exe 错误 : command failed with exit status 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30959577/

相关文章:

python - 如何防止从进行系统调用的 Django 应用程序执行任意命令?

python - 默认情况下 __eq__() 方法里面有什么

c - 通过串行通讯口将流量计读数导入Excel

mysql - 本地创建数据库时如何指定mySQL主机?

python - 如何使用python从mongodb获取游标的长度?

python - 访问不存在的版本标签上的 Google 云端点

python - Pygame 具有类似流体的特征

php - 阿拉伯语 url 在 Windows IIS 服务器上的 WordPress 中不起作用

python - 如何在python中转储不带引号的json

python - Python 2.7 中的 UnicodeDecodeError