繁体   English   中英

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 Studio\2019\BuildTools\VC\Tools\MSVC\14.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 Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.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 Settings -> Project Interpreter安装这个包。

在 Windows 10 中安装gmpy2

  1. 转到https://visualstudio.microsoft.com/downloads/并下载Visual Studio 的构建工具
  2. 运行下载的可执行文件并安装最新的 C++ 库
  3. 转到https://www.lfd.uci.edu/~gohlke/pythonlibs/并下载与您的 Python 版本相对应的gmpy2二进制文件
  4. 使用下面提到的命令安装车轮。

     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 :)

暂无
暂无

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

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