Python: "pip install gmpy" 在 Windows 10 returns "cl.exe' failed with exit status 2"
Python: "pip install gmpy" on Windows 10 returns "cl.exe' failed with exit status 2"
我在 Windows10 上安装了 Pyhton 3.7,当我 运行 pip install gmpy
控制台 return 出现这个错误时:
Collecting gmpy
Using cached https://files.pythonhosted.org/packages/26/37/2184c13cee81e1dbeaebbb13570195247e73ab2138a3db0c9d2c5347e372/gmpy-1.17.zip
Building wheels for collected packages: gmpy
Building wheel for gmpy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\setup.py'"'"'; __file__='"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\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\franc\AppData\Local\Temp\pip-wheel-nz4_kuat' --python-tag cp37
cwd: C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\
Complete output (12 lines):
running bdist_wheel
running build
running build_ext
building 'gmpy' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK.7.2\include\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /Tcsrc/gmpy.c /Fobuild\temp.win-amd64-3.7\Release\src/gmpy.obj
gmpy.c
C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\src\gmpy.h(30): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for gmpy
Running setup.py clean for gmpy
Failed to build gmpy
Installing collected packages: gmpy
Running setup.py install for gmpy ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\setup.py'"'"'; __file__='"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\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\franc\AppData\Local\Temp\pip-record-q7ltkyyx\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\
Complete output (12 lines):
running install
running build
running build_ext
building 'gmpy' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK.7.2\include\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /Tcsrc/gmpy.c /Fobuild\temp.win-amd64-3.7\Release\src/gmpy.obj
gmpy.c
C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\src\gmpy.h(30): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\setup.py'"'"'; __file__='"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\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\franc\AppData\Local\Temp\pip-record-q7ltkyyx\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
错误在这一行:
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe' failed with exit status 2
基本上这意味着 Python 需要 cl.exe
并且它期望它在:
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\bin\Hostx86\x64
没问题,我转到环境变量并为我的用户和系统添加该路径:
然后我通过在终端中输入 cl
来检查 cl.exe
是否在路径中成功并且它有效:
但是当我再次运行时pip install gmpy
我有同样的错误。
编辑: 我也尝试过 pip install gmpy2
,但我收到了同样的错误。
我哪里错了?
嗯,实际问题是你缺少一些头文件 gmp.h
:
C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\src\gmpy.h(30): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
我建议你试试 gmpy2
, which is a newer version. It has wheels for Windows on PyPI but they are for older versions of Python unfortunately. Pre-built wheels for more recent Python versions are available here。这些文件以 Python 版本(例如 cp37
代表 CPython 3.7)和体系结构(例如 amd64
代表 64 位)
命名
轮子可以这样安装:
pip install gmpy2‑2.0.8‑cp37‑cp37m‑win_amd64.whl
我在 Windows10 上安装了 Pyhton 3.7,当我 运行 pip install gmpy
控制台 return 出现这个错误时:
Collecting gmpy
Using cached https://files.pythonhosted.org/packages/26/37/2184c13cee81e1dbeaebbb13570195247e73ab2138a3db0c9d2c5347e372/gmpy-1.17.zip
Building wheels for collected packages: gmpy
Building wheel for gmpy (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\setup.py'"'"'; __file__='"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\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\franc\AppData\Local\Temp\pip-wheel-nz4_kuat' --python-tag cp37
cwd: C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\
Complete output (12 lines):
running bdist_wheel
running build
running build_ext
building 'gmpy' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK.7.2\include\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /Tcsrc/gmpy.c /Fobuild\temp.win-amd64-3.7\Release\src/gmpy.obj
gmpy.c
C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\src\gmpy.h(30): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for gmpy
Running setup.py clean for gmpy
Failed to build gmpy
Installing collected packages: gmpy
Running setup.py install for gmpy ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\setup.py'"'"'; __file__='"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\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\franc\AppData\Local\Temp\pip-record-q7ltkyyx\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\
Complete output (12 lines):
running install
running build
running build_ext
building 'gmpy' extension
creating build
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Ic:\python37\include -Ic:\python37\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK.7.2\include\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /Tcsrc/gmpy.c /Fobuild\temp.win-amd64-3.7\Release\src/gmpy.obj
gmpy.c
C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\src\gmpy.h(30): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python37\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\setup.py'"'"'; __file__='"'"'C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\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\franc\AppData\Local\Temp\pip-record-q7ltkyyx\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
错误在这一行:
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.23.28105\bin\HostX86\x64\cl.exe' failed with exit status 2
基本上这意味着 Python 需要 cl.exe
并且它期望它在:
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.23.28105\bin\Hostx86\x64
没问题,我转到环境变量并为我的用户和系统添加该路径:
然后我通过在终端中输入 cl
来检查 cl.exe
是否在路径中成功并且它有效:
但是当我再次运行时pip install gmpy
我有同样的错误。
编辑: 我也尝试过 pip install gmpy2
,但我收到了同样的错误。
我哪里错了?
嗯,实际问题是你缺少一些头文件 gmp.h
:
C:\Users\franc\AppData\Local\Temp\pip-install-du1j9u7s\gmpy\src\gmpy.h(30): fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
我建议你试试 gmpy2
, which is a newer version. It has wheels for Windows on PyPI but they are for older versions of Python unfortunately. Pre-built wheels for more recent Python versions are available here。这些文件以 Python 版本(例如 cp37
代表 CPython 3.7)和体系结构(例如 amd64
代表 64 位)
轮子可以这样安装:
pip install gmpy2‑2.0.8‑cp37‑cp37m‑win_amd64.whl