GMPY2 doesn't install

做~自己de王妃 提交于 2019-12-11 16:34:36

问题


EDIT: I'm using Win 10 and Ubuntu from the app store

I have tried to install gmpy2 by using:

apt-get install libgmp-dev
apt-get install libmpfr-dev
apt-get install libmpc-dev

and also downloaded MPIR and compiled it. however using pip install gmpy2 still gives me the error

c:\users\gypsyzz\appdata\local\temp\pip-install-l2hlf7q4\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\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

in addition, i found that using the prebuilt wheel at https://www.lfd.uci.edu/~gohlke/pythonlibs/ does not give me any functions.

import gmpy2
from gmpy2 import mpz,mpq,mpfr,mpc
gmpy2.conjugate(mpc())
Traceback (most recent call last):

File "<ipython-input-18-2d51a42bda9a>", line 1, in <module>
gmpy2.conjugate(mpc())

AttributeError: module 'gmpy2' has no attribute 'conjugate'

I'm more certain that I have understood the functions wrongly for the last part, so please let me know the correct syntax.


回答1:


This is a bug in gmpy2 2.0.x series. It has been fixed in the currently development version. gmpy2 2.1.0a2 is available on PyPi but is hidden. The following commands will install it in a user-specific directory. Python will load modules from the user-specific directory first so the new version will shadow the provided version.

sudo apt install libmpc-dev
sudo apt install python3-pip
pip3 install --user gmpy2==2.1.0a2

The new version should be backwards compatible with the old version. But if you encounter any issues, you can remove the user-specific version as follows.

pip3 uninstall gmpy2==2.1.0a2




回答2:


For me this worked:-

apt-get install libgmp3-dev (For Ubuntu, might vary for linux distro)

pip3 install gmpy --user




回答3:


If you have Anaconda installed on your system, then the simplest way of installing it would be using conda itself which will take care of all the dependencies that gmpy2 needs. The command is: conda install gmpy2



来源:https://stackoverflow.com/questions/50474091/gmpy2-doesnt-install

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!