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

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

我在这些 mpmath 之间安装了 anaconda 和 python 的许多库。 当我尝试 运行 powerlaw 包时,出现以下错误:

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

ImportError: No module named mpmath

此外,当我只是尝试做 import mpmath 时,我得到了同样的错误。

我正在使用 Fedora,我已经尝试了 yum remove python-mpmath 然后 yum install python-mpmath。但我遇到了同样的错误。

我在其他问题中看到这可能是因为我有多个路径并且我必须用 sys.path=['' 等] 添加它们。

"sys.path=['', etc]" 是什么意思?

当我这样做时:

print(sys.path)

我得到:

 ['', '/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']

您应该使用 conda 将 Python 包安装到 anaconda 中,或者如果它们无法通过 conda 使用 pip。 conda install mpmath 应该可以解决您的问题。