Python cannot locate the gmpy library … here is a solution to the problem.
Python cannot locate the gmpy library
I want to use a python script that imports gmpy. However, Python always tells me:
ImportError: There is no module named "gmpy"
I’m on Ubuntu 14.04 i686 and I’m trying to install gmpy:: in various ways
- sudo pip install gmpy
- sudo pip install gmpy2
- sudo apt-get install python-gmpy*
- sudo apt-get install python2.7-gmpy*
- sudo apt-get install python3-gmpy*
- followed the official instructions on building gmpy from source (for this reason, I also compiled MPC, MPFR, and GMP from source).
I also
Apparently I’m using python 3.4.0:
$ python
$ Python 3.4.0 (default, Apr 11 2014, 13:05:18)
[GCC 4.8.2] on linux
What am I missing so that python can’t find the gmpy library?
Solution
Either of the following solutions resolves the issue:
sudo pip3 install gmpy
(because I’m using python3, I executed the wrong pip).
or
$python2.7 script.py
(or simply use the python2 interpreter).