简体   繁体   English

Python安装编译错误

[英]Python Installation Compilation Errors

I'm hoping someone can help me since I've been stuck on this for a while, and I'm not very familiar with compiling packages. 我希望有人可以帮助我,因为我已经坚持了一段时间,而且我对编译软件包不是很熟悉。 Trying to install the following package: https://github.com/jhkorhonen/MOODS/wiki/Installation 尝试安装以下软件包: https//github.com/jhkorhonen/MOODS/wiki/Installation

Running Python 3.5 (Anaconda), Windows 10 64bit, Microsoft Visual Studio 2017 Community Edition. 运行Python 3.5(Anaconda),Windows 10 64位,Microsoft Visual Studio 2017社区版。 Here is what I did so far. 这是我到目前为止所做的。

  • Error 1: cd ed to extracted package location, and ran python setup.py install --user but got the error that says: 错误1: cd到提取的包位置,并运行python setup.py install --user但得到的错误是:

    running install running build running build_py running build_ext building 'MOODS._tools' extension cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icore/ -IC:\\Users\\Wolf\\Anaconda3\\include -IC:\\Users\\Wolf\\Anaconda3\\include /EHsc /Tpcore/tools_wrap.cxx /Fobuild\\temp.win-amd64-3.5\\Release\\core/tools_wrap.obj -march=native -O3 -fPIC --std=c++11 error: command 'cl.exe' failed: No such file or directory

  • Solution 1: Turns out C:\\Program Files (x86)\\Microsoft Visual Studio 14.0 does not have the \\VC folder it is looking for, but I did find it at C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\14.0\\VC\\bin , so I added that to PATH . 解决方案1:关闭C:\\Program Files (x86)\\Microsoft Visual Studio 14.0没有它正在寻找的\\VC文件夹,但我确实在C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\14.0\\VC\\bin找到它C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\14.0\\VC\\bin ,所以我把它添加到PATH

Then another error: 然后另一个错误:

  • Error 2: C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\14.0\\VC\\bin\\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icore/ -IC:\\Users\\Wolf\\Anaconda3\\include -IC:\\Users\\Wolf\\Anaconda3\\include /EHsc /Tpcore/tools_wrap.cxx /Fobuild\\temp.win-amd64-3.5\\Release\\core/tools_wrap.obj -march=native -O3 -fPIC --std=c++11 cl : Command line warning D9002 : ignoring unknown option '-march=native' cl : Command line warning D9002 : ignoring unknown option '-O3' cl : Command line warning D9002 : ignoring unknown option '-fPIC' cl : Command line warning D9002 : ignoring unknown option '--std=c++11' tools_wrap.cxx c:\\users\\wolf\\anaconda3\\include\\pyconfig.h(68): fatal error C1083: Cannot open include file: 'io.h': No such file or directory error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\Shared\\\\14.0\\\\VC\\\\bin\\\\cl.exe' failed with exit status 2 错误2: C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\14.0\\VC\\bin\\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icore/ -IC:\\Users\\Wolf\\Anaconda3\\include -IC:\\Users\\Wolf\\Anaconda3\\include /EHsc /Tpcore/tools_wrap.cxx /Fobuild\\temp.win-amd64-3.5\\Release\\core/tools_wrap.obj -march=native -O3 -fPIC --std=c++11 cl : Command line warning D9002 : ignoring unknown option '-march=native' cl : Command line warning D9002 : ignoring unknown option '-O3' cl : Command line warning D9002 : ignoring unknown option '-fPIC' cl : Command line warning D9002 : ignoring unknown option '--std=c++11' tools_wrap.cxx c:\\users\\wolf\\anaconda3\\include\\pyconfig.h(68): fatal error C1083: Cannot open include file: 'io.h': No such file or directory error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\Shared\\\\14.0\\\\VC\\\\bin\\\\cl.exe' failed with exit status 2
  • Solution 2: So I added an environmental variable INCLUDE and set it to C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.14393.0\\ucrt\u003c/code> , which has io.h . 方案2:所以我增加了一个环境变量INCLUDE并将其设置为C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.14393.0\\ucrt\u003c/code> ,其中有io.h

However, yet another error: 但是,又一个错误:

C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\14.0\\VC\\bin\\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Icore/ -IC:\\Users\\Wolf\\Anaconda3\\include -IC:\\Users\\Wolf\\Anaconda3\\include "-IC:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.14393.0\\ucrt\u0026quot; /EHsc /Tpcore/tools_wrap.cxx /Fobuild\\temp.win-amd64-3.5\\Release\\core/tools_wrap.obj -march=native -O3 -fPIC --std=c++11 cl : Command line warning D9002 : ignoring unknown option '-march=native' cl : Command line warning D9002 : ignoring unknown option '-O3' cl : Command line warning D9002 : ignoring unknown option '-fPIC' cl : Command line warning D9002 : ignoring unknown option '--std=c++11' tools_wrap.cxx C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.14393.0\\ucrt\\corecrt.h(10): fatal error C1083: Cannot open include file: 'vcruntime.h': No such file or directory error: command 'C:\\\\Program Files (x86)\\\\Microsoft Visual Studio\\\\Shared\\\\14.0\\\\VC\\\\bin\\\\cl.exe' failed with exit status 2

I'm not sure how to solve this. 我不知道如何解决这个问题。 It seems like adding things to PATH isn't helping a whole lot. 似乎向PATH添加东西并没有帮助很多。 Maybe it has to do with the introduction of Universal CRT? 也许它与Universal CRT的推出有关? Should I just uninstall Visual Studio 2017 and use an older version? 我应该卸载Visual Studio 2017并使用旧版本吗?

I had very similiar issue running Python 3.5 (Anaconda), Windows 10 64bit, Microsoft Visual Studio 2017 Professional Edition. 我在运行Python 3.5(Anaconda),Windows 10 64bit,Microsoft Visual Studio 2017专业版时遇到了类似的问题。

Did you try to enable a 64-Bit Visual C++ Toolset on the Command Line ? 您是否尝试在命令行上启用64位Visual C ++工具集 To do this, run vcvars64.bat on your command line first. 为此,请vcvars64.bat在命令行上运行vcvars64.bat In my case the localization is: 在我的情况下,本地化是:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build

This was sufficient for me and solved my problem. 这对我来说足够了,解决了我的问题。

In addition, I see some users have to install "Windows Universal CRT SDK" (I have it already). 另外,我看到一些用户必须安装“Windows Universal CRT SDK” (我已经有了)。 Check if you also have it: 检查您是否也有:

  1. Run Visual Studio Installer. 运行Visual Studio安装程序。
  2. Select Modify button. 选择修改按钮。
  3. Go to "Individual Components" tab. 转到“个别组件”选项卡。
  4. Scroll down to "Compilers, build tools and runtimes". 向下滚动到“编译器,构建工具和运行时”。
  5. Tick "Windows Universal CRT SDK". 勾选“Windows Universal CRT SDK”。
  6. Install. 安装。

PS: for convenience I recommend using powershell. PS:为方便起见,我建议使用powershell。 A script for setting vcvars64.bat example from here : 这里设置vcvars64.bat示例的脚本:

pushd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\"
cmd /c "vcvars64.bat&set" |
foreach {
  if ($_ -match "=") {
    $v = $_.split("="); set-item -force -path "ENV:\$($v[0])"  -value "$($v[1])"
  }
}
popd
Write-Host "`nVisual Studio 2017 Command Prompt variables set." -ForegroundColor Yellow

you can also download and install window 10 sdk independently, 你也可以独立下载和安装window 10 sdk

using this link, hope it solves the issue. 使用此链接,希望它解决问题。

2nd try to use the the visual studio command propmpt eg Vs2017 x64 Native Tools command prompt and then try the compilation process. 第二次尝试使用visual studio命令提示符,例如Vs2017 x64 Native Tools命令提示符,然后尝试编译过程。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM