python - 使用 Python 2 的 Anaconda 发行版安装 gmpy (Windows)

标签 python anaconda gmpy

我正在尝试使用名为 CatMAP 的程序这大量使用了 gmpy 依赖项(根据安装说明,我认为它是 gmpy,而不是 gmpy2)。

我通过 Anaconda 有 Python 2.7.12,但在安装 gmpy 时遇到很多麻烦。执行 pip install gmpy 不起作用,我在 Anaconda Cloud 上找到的所有版本都适用于 Linux。有什么建议吗?

来自pip install方法的错误消息如下所示:

Collecting gmpy
  Using cached gmpy-1.17.zip
Building wheels for collected packages: gmpy
  Running setup.py bdist_wheel for gmpy ... error
  Complete output from command C:\Users\andre\Anaconda3\envs\python2\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\andre\\appdata\\local\\temp\\pip-build-wu9jm7\\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\andre\appdata\local\temp\tmphhh_2jpip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_ext
  building 'gmpy' extension
  creating build
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  creating build\temp.win-amd64-2.7\Release\src
  C:\Users\andre\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Users\andre\Anaconda3\envs\python2\include -IC:\Users\andre\Anaconda3\envs\python2\PC /Tcsrc/gmpy.c /Fobuild\temp.win-amd64-2.7\Release\src/gmpy.obj
  gmpy.c
  c:\users\andre\appdata\local\temp\pip-build-wu9jm7\gmpy\src\gmpy.h(30) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
  error: command 'C:\\Users\\andre\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

  ----------------------------------------
  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
    Complete output from command C:\Users\andre\Anaconda3\envs\python2\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\andre\\appdata\\local\\temp\\pip-build-wu9jm7\\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\andre\appdata\local\temp\pip-uvzbnt-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'gmpy' extension
    creating build
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    creating build\temp.win-amd64-2.7\Release\src
    C:\Users\andre\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Users\andre\Anaconda3\envs\python2\include -IC:\Users\andre\Anaconda3\envs\python2\PC /Tcsrc/gmpy.c /Fobuild\temp.win-amd64-2.7\Release\src/gmpy.obj
    gmpy.c
    c:\users\andre\appdata\local\temp\pip-build-wu9jm7\gmpy\src\gmpy.h(30) : fatal error C1083: Cannot open include file: 'gmp.h': No such file or directory
    error: command 'C:\\Users\\andre\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "C:\Users\andre\Anaconda3\envs\python2\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\andre\\appdata\\local\\temp\\pip-build-wu9jm7\\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\andre\appdata\local\temp\pip-uvzbnt-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\andre\appdata\local\temp\pip-build-wu9jm7\gmpy\

最佳答案

由于 CatMAP 使用 mpmath,因此很有可能仅需要 gmpy 来提高 mpmath 的性能。假设这是真的,则 gmpy2 将起作用,因为 mpmath 支持 gmpygmpy2

您可以找到 gmpygmpy2 的 pip 兼容轮 here

关于python - 使用 Python 2 的 Anaconda 发行版安装 gmpy (Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41081022/

相关文章:

python - 使用 matplotlib 在一个循环内的两个独立图形窗口中的子图

Python 调用 makefile 编译并捕获 make 的输出

python - 使用 Python 将电子邮件发送到带有内联图像的 Gmail

python - Python 和 Anaconda 的混淆

python - 使用预编译的二进制文件在 Windows 上安装 gmpy2

python - flask:如何桥接前端和后端服务以呈现 api 身份验证?

python-3.x - 使用机器学习算法时无法将字符串转换为 float (python 3) (Anaconda)

python - 如何在Anaconda环境中运行包?

python - GMPY2安装: DLL load failed: %1 is not a valid Win32 application