Windows 10 安装python时出错:';cl.exe';失败,退出状态为2

Windows 10 安装python时出错:';cl.exe';失败,退出状态为2,windows-10,cython,python-3.5,Windows 10,Cython,Python 3.5,我试图在python3.5(x64)上安装glove python包,但出现了如下所示的错误 注意,我在微软Windows 10上安装了TDM GCC-64、明文32、明文64、CygWin、MySoT Visual C++、PysVisual 2008(X64)和微软Visual C++ 2.7(X64),可重新分配,以解决问题。 我尝试了许多解决方案,比如创建distutils.cfg文件来使用mingw32/cygwin/mingw64构建包,但所有的尝试都给了我不同的错误!所以我删除了d

我试图在python3.5(x64)上安装glove python包,但出现了如下所示的错误

注意,我在微软Windows 10上安装了TDM GCC-64、明文32、明文64、CygWin、MySoT Visual C++、PysVisual 2008(X64)和微软Visual C++ 2.7(X64),可重新分配,以解决问题。 我尝试了许多解决方案,比如创建distutils.cfg文件来使用mingw32/cygwin/mingw64构建包,但所有的尝试都给了我不同的错误!所以我删除了distutils.cfg文件,但这也给了我一个错误,如下所示

注意:错误中写的路径是针对Python 2.7的微软Visual C++(但我使用Python 35),因此这可能是错误的原因?

我也觉得这个错误可能是由于Cython没有运行。我使用pip安装了Cython 0.25.2。但是当我运行pycharm调试器时,它会给我一个警告,调试器没有找到使用Cython的加速。另外,我在构建“glood.glood\u Cython”时出现了错误(在尝试以不同方式安装包的过程中)

以下是错误:

C:\Users\ESCA>pip3 install glove-python
Collecting glove-python
Using cached glove_python-0.1.0.tar.gz
Requirement already satisfied: numpy in c:\users\esca\appdata\local\programs\python\python35\lib\site-packages (from glove-python)
Requirement already satisfied: scipy in c:\users\esca\appdata\local\programs\python\python35\lib\site-packages (from glove-python)
Building wheels for collected packages: glove-python
Running setup.py bdist_wheel for glove-python ... error
Complete output from command c:\users\esca\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ESCA\\AppData\\Local\\Temp\\pip-build-4tm726dc\\glove-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\ESCA\AppData\Local\Temp\tmp0war2fdwpip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.5
creating build\lib.win-amd64-3.5\glove
copying glove\corpus.py -> build\lib.win-amd64-3.5\glove
copying glove\glove.py -> build\lib.win-amd64-3.5\glove
copying glove\__init__.py -> build\lib.win-amd64-3.5\glove
running build_ext
building 'glove.glove_cython' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\glove
C:\Users\ESCA\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\users\esca\appdata\local\programs\python\python35\include -Ic:\users\esca\appdata\local\programs\python\python35\include /Tcglove/glove_cython.c /Fobuild\temp.win-amd64-3.5\Release\glove/glove_cython.obj -fopenmp -ffast-math -march=native
 cl : Command line warning D9002 : ignoring unknown option '-fopenmp'
 cl : Command line warning D9002 : ignoring unknown option '-ffast-math'
 cl : Command line warning D9002 : ignoring unknown option '-march=native'
 glove_cython.c
 c:\users\esca\appdata\local\programs\python\python35\include\pyconfig.h(68) : fatal error C1083: Cannot open include file: 'io.h': No such file or directory
error: command 'C:\\Users\\ESCA\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\bin\\cl.exe' failed with exit status 2

----------------------------------------
Failed building wheel for glove-python
Running setup.py clean for glove-python
Complete output from command c:\users\esca\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ESCA\\AppData\\Local\\Temp\\pip-build-4tm726dc\\glove-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" clean --all:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
 or: -c --help [cmd1 cmd2 ...]
 or: -c --help-commands
 or: -c cmd --help

error: option --all not recognized

----------------------------------------
Failed cleaning build dir for glove-python
Failed to build glove-python
Installing collected packages: glove-python
Running setup.py install for glove-python ... error
Complete output from command c:\users\esca\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ESCA\\AppData\\Local\\Temp\\pip-build-4tm726dc\\glove-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ESCA\AppData\Local\Temp\pip-gs05_i6s-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
running build_ext
building 'glove.glove_cython' extension
C:\Users\ESCA\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\users\esca\appdata\local\programs\python\python35\include -Ic:\users\esca\appdata\local\programs\python\python35\include /Tcglove/glove_cython.c /Fobuild\temp.win-amd64-3.5\Release\glove/glove_cython.obj -fopenmp -ffast-math -march=native
cl : Command line warning D9002 : ignoring unknown option '-fopenmp'
cl : Command line warning D9002 : ignoring unknown option '-ffast-math'
cl : Command line warning D9002 : ignoring unknown option '-march=native'
glove_cython.c
c:\users\esca\appdata\local\programs\python\python35\include\pyconfig.h(68) : fatal error C1083: Cannot open include file: 'io.h': No such file or directory
error: command 'C:\\Users\\ESCA\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\bin\\cl.exe' failed with exit status 2

----------------------------------------
Command "c:\users\esca\appdata\local\programs\python\python35\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ESCA\\AppData\\Local\\Temp\\pip-build-4tm726dc\\glove-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ESCA\AppData\Local\Temp\pip-gs05_i6s-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ESCA\AppData\Local\Temp\pip-build-4tm726dc\glove-python\

在编译时,请尝试此
setup.py
,它适用于Windows x64计算机中的默认安装目录:

from Cython.Distutils import build_ext
import numpy as np
import os

try:
    from setuptools import setup
    from setuptools import Extension
except ImportError:
    from distutils.core import setup
    from distutils.extension import Extension

module = 'mymodule'

ext_modules = [Extension(module, sources=[module + '.pyx'],
              include_dirs=['C://Program Files (x86)//Windows Kits//10//Include//10.0.10240.0//ucrt','C://Program Files (x86)//Microsoft Visual Studio 14.0//VC//include','C://Program Files (x86)//Windows Kits//8.1//Include//shared'],
              library_dirs=['C://Program Files (x86)//Windows Kits//8.1//bin//x64', 'C://Windows//System32', 'C://Program Files (x86)//Microsoft Visual Studio 14.0//VC//lib//amd64', 'C://Program Files (x86)//Windows Kits//8.1//Lib//winv6.3//um//x64', 'C://Program Files (x86)//Windows Kits//10//Lib//10.0.10240.0//ucrt//x64'], 
              extra_compile_args=['/Ot', '/favor:INTEL64', '/EHsc', '/GA', '/openmp'],
              language='c++')]

setup(
    name = module,
    ext_modules = ext_modules,
    cmdclass = {'build_ext': build_ext},
    include_dirs = [np.get_include(), os.path.join(np.get_include(), 'numpy')]
    )

注意,上面可能需要对每个include目录的路径以及正在安装的包进行一些认真的编辑。您最好使用Windows x64上的Python 3.5安装Visual Studio 2015 Community,然后从VS命令提示符执行
Python setup.py安装
,为您设置所有包含目录,安装Community后出现的VS2015的
VS2015 x64本机工具
MSBuild命令提示符。请注意,VS2015版本要求社区至少构建Python模块,因为它们摆脱了以前通过Microsoft可再发行文件进行编译的能力。

请尝试此
setup.py
而不是在Windows x64计算机中的默认安装目录下进行编译:

from Cython.Distutils import build_ext
import numpy as np
import os

try:
    from setuptools import setup
    from setuptools import Extension
except ImportError:
    from distutils.core import setup
    from distutils.extension import Extension

module = 'mymodule'

ext_modules = [Extension(module, sources=[module + '.pyx'],
              include_dirs=['C://Program Files (x86)//Windows Kits//10//Include//10.0.10240.0//ucrt','C://Program Files (x86)//Microsoft Visual Studio 14.0//VC//include','C://Program Files (x86)//Windows Kits//8.1//Include//shared'],
              library_dirs=['C://Program Files (x86)//Windows Kits//8.1//bin//x64', 'C://Windows//System32', 'C://Program Files (x86)//Microsoft Visual Studio 14.0//VC//lib//amd64', 'C://Program Files (x86)//Windows Kits//8.1//Lib//winv6.3//um//x64', 'C://Program Files (x86)//Windows Kits//10//Lib//10.0.10240.0//ucrt//x64'], 
              extra_compile_args=['/Ot', '/favor:INTEL64', '/EHsc', '/GA', '/openmp'],
              language='c++')]

setup(
    name = module,
    ext_modules = ext_modules,
    cmdclass = {'build_ext': build_ext},
    include_dirs = [np.get_include(), os.path.join(np.get_include(), 'numpy')]
    )
注意,上面可能需要对每个include目录的路径以及正在安装的包进行一些认真的编辑。您最好使用Windows x64上的Python 3.5安装Visual Studio 2015 Community,然后从VS命令提示符执行
Python setup.py安装
,为您设置所有包含目录,安装Community后出现的VS2015的
VS2015 x64本机工具
MSBuild命令提示符。请注意,VS2015版本要求社区至少构建Python模块,因为它们摆脱了以前通过Microsoft可再发行文件进行编译的能力