ImportError: No module named mpmath. But mpmath has been installed. What's wrong?

RM- picture RM- · Jan 11, 2015 · Viewed 7k times · Source

I have anaconda installed and many libraries of python, between those mpmath. When I try to run powerlaw package I get the following error:

-> 1466         from mpmath import erfc
   1467 #        from scipy.special import erfc
   1468         from scipy.constants import pi

ImportError: No module named mpmath

Furthermore when I simply try to do import mpmath I get the same error.

I'm using Fedora, I have already tried yum remove python-mpmath and then yum install python-mpmath. But I'm getting the same error.

I have seen in other questions that this might be because I have multiple paths and that I must add them both with a sys.path=['', etc].

What does "sys.path=['', etc]" mean?

When I do:

print(sys.path)

I get:

 ['', '/home/rm/anaconda/bin', '/home/rm/anaconda/lib/python27.zip',  '/home/rm/anaconda/lib/python2.7', '/home/rm/anaconda/lib/python2.7/plat-linux2', '/home/rm/anaconda/lib/python2.7/lib-tk', '/home/rm/anaconda/lib/python2.7/lib-old', 
'/home/rm/anaconda/lib/python2.7/lib-dynload', '/home/rm/anaconda/lib/python2.7/site-packages',  '/home/rm/anaconda/lib/python2.7/site-packages/PIL', '/home/rm/anaconda/lib/python2.7/site-packages/runipy-0.1.0-py2.7.egg', '/home/rm/anaconda/lib/python2.7/site-packages/setuptools-3.6-py2.7.egg', '/home/rm/anaconda/lib/python2.7/site-packages/IPython/extensions', 
'/home/rm/.ipython']

Answer

asmeurer picture asmeurer · Jan 27, 2015

You should use conda to install Python packages into anaconda, or pip if they are not available via conda. conda install mpmath should fix your issue.