简体   繁体   English

Python distutils拒绝识别已安装的C ++编译器,“无法在Python 3.5下找到vcvarsall.bat”

[英]Python distutils refuses to recognise installed C++ compilers, `Unable to find vcvarsall.bat` under Python 3.5

I'm tearing my hair out trying to compile c though Python's distutils. 我正在试图通过Python的distutils来编译c。 Specifically I'm trying to get started with Cython following this guide: http://docs.cython.org/src/quickstart/build.html , using a setup.py. 具体来说,我正在尝试按照本指南开始使用Cython: http ://docs.cython.org/src/quickstart/build.html,使用setup.py。

I'm running Python 3.5.0 under Anaconda 2.4.0 (64-bit), Windows 7. 我在Anaconda 2.4.0(64位),Windows 7下运行Python 3.5.0。

I get the Unable to find vcvarsall.bat error referred to here: Cannot find vcvarsall.bat when running a Python script and in various other questions. 我找到了Unable to find vcvarsall.bat这里提到的Unable to find vcvarsall.bat错误: 在运行Python脚本时遇到vcvarsall.bat以及其他各种问题。

None of the proposed solutions work for me . 所提出的解决方案都不适合我 So far I have tried: 到目前为止,我尝试过:

  • installing Visual Studio - I have all versions from 2008 to 2013, ie 9.0, 10.0, 11.0, and 12.0. 安装Visual Studio - 我有从2008年到2013年的所有版本,即9.0,10.0,11.0和12.0。
  • pointing environment variables (VS100COMNTOOLS etc) related to the above directly to the correct locations 将与上述相关的环境变量(VS100COMNTOOLS等)直接指向正确的位置
  • installing Microsoft Visual C++ Compiler for Python (as above link). 安装Microsoft Visual C ++ Compiler for Python(如上所述)。 This seemed to work but I get a compilation error that seems to be an incompatibility; 这似乎工作,但我得到一个似乎不兼容的编译错误; I think because the compiler is intended for Python 2.7. 我认为因为编译器适用于Python 2.7。
  • Ravi Kumar's suggestion at the above link to update pip's setuptools. Ravi Kumar在上述链接中建议更新pip的setuptools。 Pip gave me an error saying it couldn't update. 皮普给了我一个错误,说无法更新。
  • Installing MS Windows SDK for Windows 7 and .NET Framework 4 as https://github.com/cython/cython/wiki/CythonExtensionsOnWindows . 安装MS Windows SDK for Windows 7和.NET Framework 4为https://github.com/cython/cython/wiki/CythonExtensionsOnWindows The final step failed with an error message that the x64 compilers aren't currently installed. 最后一步失败,并显示当前未安装x64编译器的错误消息。

The only thing I can think of is installing MinGW which I've seen suggested in some places, but that CythonExtensionsOnWindows link specifically recommended against it. 我唯一能想到的是安装MinGW,我已经在一些地方看到了建议,但CythonExtensionsOnWindows链接专门建议反对它。

Any other suggestions would be very welcome! 任何其他建议将是非常受欢迎的! In particular, since I clearly have all the versions of VS I could possibly need, is there a way to force Python to recognise them, other than setting environment variables VS100COMNTOOLS or similar? 特别是,因为我清楚地拥有了我可能需要的VS的所有版本,除了设置环境变量VS100COMNTOOLS或类似之外,有没有办法强制Python识别它们?

Interestingly conda does seem to recognise the installed compilers, as a separate pip install attempt that failed with this same error, worked with conda. 有趣的是康达似乎以识别安装的编译器,作为一个单独的PIP安装尝试与此相同的错误失败,与康达合作。

As it turns out, Python 3.5 needs Visual Studio 2015. Advice elsewhere on fixing this for other Python versions is outdated. 事实证明,Python 3.5需要Visual Studio 2015.其他地方为其他Python版本修复此问题的建议已经过时。

Get Visual Studio 2015 Community here: https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx , this worked for me with no further steps needed. 在这里获取Visual Studio 2015社区: https//www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx ,这对我有用,无需进一步的步骤。

Many thanks to Ionel, apparently the only place on the web to find this information! 非常感谢Ionel,显然是网上唯一能找到这些信息的地方! http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/ http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:需要Microsoft Visual C ++ 10.0(无法找到vcvarsall.bat)。 在Windows 10 64位上安装Scrapy时 - error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat). while installing Scrapy on Windows 10 64-bit MinGW编译器在出现“找不到vcvarsall.bat”错误后为pip仍然无法正常工作 - MinGW compiler for pip after “cannot find vcvarsall.bat” error, still does not work python / c ++ - 使用cmake编译共享库并使用distutils进行安装 - python/c++ - Compiling shared library with cmake and installing with distutils 为什么Visual Studio不安装vcvarsall.bat和DIA SDK - Why Visual Studio doesn't install vcvarsall.bat and DIA SDK 为什么 iostream 需要在使用 vcvarsall.bat 编译“Hello World”时调用异常处理程序? - Why does iostream require the exception handler to be called while using vcvarsall.bat to compile 'Hello World'? Python / C++ 绑定,如何使用 distutils 重新链接静态 C++ 库(portaudio)? - Python / C++ binding, how to link agains static c++ library (portaudio) with distutils? 嵌入 Python 的 C++:如果未安装 Python,则崩溃 - C++ with Python embedding: crash if Python not installed 如何让visual studio代码直接运行vcvarsx86_arm64.bat而不是vcvarsall.bat? - How to make visual studio code run vcvarsx86_arm64.bat instead of vcvarsall.bat directly? 在Linux下使用distutils交叉编译python扩展 - Cross-compiling python extensions under Linux using distutils 如何在Mac OSX上使用distutils使用python C ++扩展编译OpenGL? - How to compile OpenGL with a python C++ extension using distutils on Mac OSX?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM