Python安装编译错误 [英] Python Installation Compilation Errors

查看:353
本文介绍了Python安装编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我坚持了一段时间以来,我希望有人能为我提供帮助,而且我对编译软件包不是很熟悉.尝试安装以下软件包: https://github.com/jhkorhonen/MOODS/wiki/Installation

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

运行Python 3.5(Anaconda),Windows 10 64位,Microsoft Visual Studio 2017社区版.这是我到目前为止所做的.

Running Python 3.5 (Anaconda), Windows 10 64bit, Microsoft Visual Studio 2017 Community Edition. Here is what I did so far.

  • 错误1:cd到提取的程序包位置,并运行python setup.py install --user,但显示以下错误:

  • Error 1:cded to extracted package location, and ran python setup.py install --user but got the error that says:

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

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

解决方案1:原来C:\Program Files (x86)\Microsoft Visual Studio 14.0没有要查找的\VC文件夹,但是我确实在C:\Program Files (x86)\Microsoft Visual Studio\Shared\14.0\VC\bin上找到了它,所以我将其添加到了PATH中.

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.

然后出现另一个错误:

  • 错误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:所以我添加了一个环境变量INCLUDE并将其设置为 到具有io.hC:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\ucrt.
  • 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
  • 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, which has io.h.

但是,另一个错误:

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" /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

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" /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

我不确定该如何解决.似乎将内容添加到PATH并没有太大帮助.也许与通用CRT的推出有关?我应该只卸载Visual Studio 2017并使用旧版本吗?

I'm not sure how to solve this. It seems like adding things to PATH isn't helping a whole lot. Maybe it has to do with the introduction of Universal CRT? Should I just uninstall Visual Studio 2017 and use an older version?

推荐答案

我在运行Python 3.5(Anaconda),Windows 10 64bit,Microsoft Visual Studio 2017 Professional Edition时遇到了非常类似的问题.

I had very similiar issue running Python 3.5 (Anaconda), Windows 10 64bit, Microsoft Visual Studio 2017 Professional Edition.

您是否尝试在命令行上启用64位Visual C ++工具集? 为此,请首先在命令行上运行vcvars64.bat. 在我的情况下,本地化为:

Did you try to enable a 64-Bit Visual C++ Toolset on the Command Line? To do this, run vcvars64.bat on your command line first. 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.

此外,我看到一些用户必须安装"Windows Universal CRT SDK" (我已经拥有了).检查您是否也拥有它:

In addition, I see some users have to install "Windows Universal CRT SDK" (I have it already). Check if you also have it:

  1. 运行Visual Studio安装程序.
  2. 选择修改"按钮.
  3. 转到单个组件"标签.
  4. 向下滚动到编译器,构建工具和运行时".
  5. 勾选"Windows Universal CRT SDK".
  6. 安装.

PS:为方便起见,我建议使用Powershell.用于在此处设置vcvars64.bat示例的脚本:

PS: for convenience I recommend using powershell. A script for setting vcvars64.bat example from here:

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

这篇关于Python安装编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆