我正在尝试使用 pip 在我的 Anaconda Python 3.5 发行版上安装 gmpy2。我能够完美地安装其他模块,例如 primefac。当我尝试安装 gmpy2 时,这是我得到的:
(C:\Program Files\Anaconda3) C:\WINDOWS\system32>pip install gmpy2
Collecting gmpy2
Using cached gmpy2-2.0.8.zip
Building wheels for collected packages: gmpy2
Running setup.py bdist_wheel for gmpy2 ... error
Complete output from command "C:\Program Files\Anaconda3\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\HADIKH~1\\AppData\\Local\\Temp\\pip-build-hd7b270n\\gmpy2\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\HADIKH~1\AppData\Local\Temp\tmplefsjn80pip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_ext
building 'gmpy2' extension
creating build
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\src
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DMPIR -DWITHMPFR -DWITHMPC "-IC:\Program Files\Anaconda3\include" "-IC:\Program Files\Anaconda3\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\winrt" /Tcsrc\gmpy2.c /Fobuild\temp.win-amd64-3.5\Release\src\gmpy2.obj
gmpy2.c
c:\users\hadi khan\appdata\local\temp\pip-build-hd7b270n\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 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
Failed building wheel for gmpy2
我注意到,每当我尝试在计算机上安装 gmpy2 时,我总是会遇到某种错误,而且每次都不同。谁能告诉我如何解决这个问题。
谢谢。
最佳答案
原因是一些必需的包(尤其是下面的包)没有安装。
- GMP:GNU 多精度算术库
- MPFR:GNU 多精度浮点舍入库
- MPC:GNU 多精度 C 库
您可以通过以下命令安装这些软件包:
apt-get install libgmp-dev
apt-get install libmpfr-dev
apt-get install libmpc-dev
我可以通过安装这些库来安装 gmpy2。
关键是当你遇到上面的错误时,记住下面的提示。
#include "***.h": ==> No such file or directory
apt-get install lib"***"-dev
关于python - GMPY2 未安装,未找到 mpir.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40075271/