Python unable to locate gmpy library

18k Views Asked by At

I want to use a python script which imports gmpy. However, python always tells me:

ImportError: No module named 'gmpy'

I am on Ubuntu 14.04 i686 and I tried to install gmpy over various ways:

  1. sudo pip install gmpy
  2. sudo pip install gmpy2
  3. sudo apt-get install python-gmpy*
  4. sudo apt-get install python2.7-gmpy*
  5. sudo apt-get install python3-gmpy*
  6. I also followed the officiel instruction on building gmpy from source (I also compiled MPC, MPFR, and GMP from source for this reason).

Obviously I am 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 such that python is not able to find the gmpy libs?

2

There are 2 best solutions below

1
On

Any of the following solutions solved the problem:

sudo pip3 install gmpy (I executed the wrong pip as I am using python3)

or

$ python2.7 script.py (Or simply use python2 interpreter)

1
On
  • apt-get -f install
  • pip2 install gmpy

Done.