Python 3.7:无法在 Windows 10 的 venv 中安装 gmpy2
Python 3.7: Unable to install gmpy2 in a venv in Windows 10
我正在尝试在 Windows 10.
的虚拟环境中安装 gmpy2
最初,我遇到了以下错误。
Collecting gmpy2
Using cached https://files.pythonhosted.org/packages/90/f4/9a2e384b325b69bc5827b9a6510a8fb4a51698c915c06a3f25a86458892a/gmpy2-2.0.8.zip
Installing collected packages: gmpy2
Running setup.py install for gmpy2: started
Running setup.py install for gmpy2: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-p2f519dp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2'
cwd: C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\
Complete output (5 lines):
running install
running build
running build_ext
building 'gmpy2' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-p2f519dp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2' Check the logs for full command output.
我能够通过从 https://visualstudio.microsoft.com/downloads/.
安装 Visual Studio 的构建工具来克服这个错误
我又试了一次,这次我得到了以下错误。
Collecting gmpy2
Using cached https://files.pythonhosted.org/packages/90/f4/9a2e384b325b69bc5827b9a6510a8fb4a51698c915c06a3f25a86458892a/gmpy2-2.0.8.zip
Installing collected packages: gmpy2
Running setup.py install for gmpy2: started
Running setup.py install for gmpy2: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-i495p48z\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2'
cwd: C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\
Complete output (12 lines):
running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.24.28314\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DMPIR -DWITHMPFR -DWITHMPC -IC:\Workspace\path\to\project\venv\include -IC:\Users\biles\AppData\Local\Programs\Python\Python37-32\include -IC:\Users\biles\AppData\Local\Programs\Python\Python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.24.28314\include" "-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\gmpy2.c /Fobuild\temp.win32-3.7\Release\src\gmpy2.obj
gmpy2.c
C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\src\gmpy.h(104): fatal error C1083: Cannot open include file: 'mpir.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-i495p48z\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2' Check the logs for full command output.
我尝试将版本指定为 2.1.0a4
,然后指定为 2.1.0a2
,然后指定为 2.0.8
。但是我得到了同样的错误。
注意:我正在尝试通过 PyCharm 设置 -> 项目解释器.[=19 安装这个包=]
在 Windows 10
中安装 gmpy2
- 转到 https://visualstudio.microsoft.com/downloads/ 并下载 Visual Studio
的构建工具
- 运行 下载的可执行文件并安装最新的 C++ 库
- 转到 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 并下载与您的 Python
版本相对应的 gmpy2
二进制文件
使用下面提到的命令安装轮子。
pip install C:\path\to\wheel\gmpy2-2.0.8-cp37-cp37m-win32.whl
使用这些步骤,我能够在我的虚拟环境中成功安装 gmpy2
。请参考以下截图。
注意: 在我的例子中是 gmpy2-2.0.8-cp37-cp37m-win32.whl
因为我的项目解释器是 Python 3.7
。文件名中的cp37
表示CPython 3.7
。如果您没有获得正确的二进制文件,您将收到以下错误。
gmpy2-2.0.8-cp38-cp38-win32.whl is not a supported wheel on this platform.
谢谢@keiv.fly:)
我正在尝试在 Windows 10.
的虚拟环境中安装gmpy2
最初,我遇到了以下错误。
Collecting gmpy2
Using cached https://files.pythonhosted.org/packages/90/f4/9a2e384b325b69bc5827b9a6510a8fb4a51698c915c06a3f25a86458892a/gmpy2-2.0.8.zip
Installing collected packages: gmpy2
Running setup.py install for gmpy2: started
Running setup.py install for gmpy2: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-p2f519dp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2'
cwd: C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\
Complete output (5 lines):
running install
running build
running build_ext
building 'gmpy2' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-p2f519dp\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2' Check the logs for full command output.
我能够通过从 https://visualstudio.microsoft.com/downloads/.
安装 Visual Studio 的构建工具来克服这个错误我又试了一次,这次我得到了以下错误。
Collecting gmpy2
Using cached https://files.pythonhosted.org/packages/90/f4/9a2e384b325b69bc5827b9a6510a8fb4a51698c915c06a3f25a86458892a/gmpy2-2.0.8.zip
Installing collected packages: gmpy2
Running setup.py install for gmpy2: started
Running setup.py install for gmpy2: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-i495p48z\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2'
cwd: C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\
Complete output (12 lines):
running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.24.28314\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DMPIR -DWITHMPFR -DWITHMPC -IC:\Workspace\path\to\project\venv\include -IC:\Users\biles\AppData\Local\Programs\Python\Python37-32\include -IC:\Users\biles\AppData\Local\Programs\Python\Python37-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\BuildTools\VC\Tools\MSVC.24.28314\include" "-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\gmpy2.c /Fobuild\temp.win32-3.7\Release\src\gmpy2.obj
gmpy2.c
C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\src\gmpy.h(104): fatal error C1083: Cannot open include file: 'mpir.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x86\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Workspace\path\to\project\venv\Scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\setup.py'"'"'; __file__='"'"'C:\Users\biles\AppData\Local\Temp\pycharm-packaging\gmpy2\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\biles\AppData\Local\Temp\pip-record-i495p48z\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Workspace\path\to\project\venv\include\site\python3.7\gmpy2' Check the logs for full command output.
我尝试将版本指定为 2.1.0a4
,然后指定为 2.1.0a2
,然后指定为 2.0.8
。但是我得到了同样的错误。
注意:我正在尝试通过 PyCharm 设置 -> 项目解释器.[=19 安装这个包=]
在 Windows 10
中安装gmpy2
- 转到 https://visualstudio.microsoft.com/downloads/ 并下载 Visual Studio 的构建工具
- 运行 下载的可执行文件并安装最新的 C++ 库
- 转到 https://www.lfd.uci.edu/~gohlke/pythonlibs/ 并下载与您的 Python 版本相对应的
使用下面提到的命令安装轮子。
pip install C:\path\to\wheel\gmpy2-2.0.8-cp37-cp37m-win32.whl
gmpy2
二进制文件
使用这些步骤,我能够在我的虚拟环境中成功安装 gmpy2
。请参考以下截图。
注意: 在我的例子中是 gmpy2-2.0.8-cp37-cp37m-win32.whl
因为我的项目解释器是 Python 3.7
。文件名中的cp37
表示CPython 3.7
。如果您没有获得正确的二进制文件,您将收到以下错误。
gmpy2-2.0.8-cp38-cp38-win32.whl is not a supported wheel on this platform.
谢谢@keiv.fly:)