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
问题描述
我正在努力尝试通过Python的distutils编译c.具体来说,我正在尝试按照本指南使用Cython: http://docs.cython.org/src/quickstart/build.html ,使用setup.py.
I'm tearing my hair out trying to compile c though Python's distutils. Specifically I'm trying to get started with Cython following this guide: http://docs.cython.org/src/quickstart/build.html, using a setup.py.
我正在Windows 7的Anaconda 2.4.0(64位)下运行Python 3.5.0.
I'm running Python 3.5.0 under Anaconda 2.4.0 (64-bit), Windows 7.
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.
所有提议的解决方案都不适合我.到目前为止,我已经尝试过:
None of the proposed solutions work for me. So far I have tried:
- 安装Visual Studio-我具有从2008年到2013年的所有版本,即9.0、10.0、11.0和12.0.
- 将与上述内容相关的环境变量(VS100COMNTOOLS等)直接指向正确的位置
- 安装适用于Python的Microsoft Visual C ++编译器(如上述链接).这似乎可行,但是出现了似乎不兼容的编译错误.我认为是因为该编译器适用于Python 2.7.
- Ravi Kumar在上述链接上的建议可更新pip的setuptools.Pip给我一个错误,说它无法更新.
- 将Windows 7和.NET Framework 4的MS Windows SDK安装为 https://github.com/cython/cython/wiki/CythonExtensionsOnWindows .最后一步失败,并显示一条错误消息,指出当前未安装x64编译器.
- installing Visual Studio - I have all versions from 2008 to 2013, ie 9.0, 10.0, 11.0, and 12.0.
- pointing environment variables (VS100COMNTOOLS etc) related to the above directly to the correct locations
- installing Microsoft Visual C++ Compiler for Python (as above link). 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.
- Ravi Kumar's suggestion at the above link to update pip's 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. The final step failed with an error message that the x64 compilers aren't currently installed.
我唯一能想到的就是安装MinGW,我在某些地方建议这样做,但是特别建议不要使用CythonExtensionsOnWindows链接.
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.
任何其他建议将非常受欢迎!特别是,由于我显然拥有了我可能需要的所有VS版本,除了设置环境变量VS100COMNTOOLS或类似变量之外,是否有一种方法可以强制Python识别它们?
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?
有趣的是,conda 确实能够识别已安装的编译器,因为单独的pip安装尝试因此相同的错误而失败,并且与conda一起使用.
Interestingly conda does seem to recognise the installed compilers, as a separate pip install attempt that failed with this same error, worked with conda.
推荐答案
事实证明,Python 3.5需要Visual Studio2015.针对其他Python版本修复此问题的建议已过时.
As it turns out, Python 3.5 needs Visual Studio 2015. Advice elsewhere on fixing this for other Python versions is outdated.
在此处获取Visual Studio 2015社区: https://www.visualstudio.com/zh-CN/downloads/visual-studio-2015-downloads-vs.aspx ,这对我有用,不需要其他步骤.
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.
非常感谢Ionel,它显然是Web上唯一可找到此信息的地方! http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/
Many thanks to Ionel, apparently the only place on the web to find this information! http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/
这篇关于Python distutils拒绝识别已安装的C ++编译器,“在Python 3.5下找不到vcvarsall.bat"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!