Python3.7:无法在Windows10的venv中安装gmpy2

2024-04-23 16:13:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图在Windows10的虚拟环境中安装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/安装用于visualstudio的构建工具克服了这个错误。你知道吗

我再试了一次,这一次我得到了以下错误。你知道吗

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设置->;项目解释器安装此软件包。你知道吗


Tags: installpyincludelocalsetuprecordusersappdata
1条回答
网友
1楼 · 发布于 2024-04-23 16:13:40

在Windows10中安装gmpy2

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

    pip install C:\path\to\wheel\gmpy2-2.0.8-cp37-cp37m-win32.whl
    

使用这些步骤,我能够在我的虚拟环境中成功地安装gmpy2。请参考以下截图。你知道吗

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

相关问题 更多 >