gypsyzz
gypsyzz

Reputation: 43

GMPY2 doesn't install

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.

Upvotes: 3

Views: 25253

Answers (3)

user10633032
user10633032

Reputation:

For me this worked:

apt-get install libgmp3-dev # For Ubuntu, might vary by Linux distro
pip3 install gmpy --user

Upvotes: 0

Tanuj Chakraborty
Tanuj Chakraborty

Reputation: 41

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

Upvotes: 0

casevh
casevh

Reputation: 11394

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

Upvotes: 11

Related Questions