GMPY2 doesn't install

gypsyzz picture gypsyzz · May 22, 2018 · Viewed 14.8k times · Source

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.

Answer

casevh picture casevh · May 27, 2018

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