Module Successfully Installed, but Not Found in IPython

佐手、 提交于 2019-12-04 06:24:07

问题


I have installed the package bigfloat and the MPFR and GMP libraries. When I run python in the terminal (I use a Mac), bigfloat can be imported and works successfully. However, I typically write my scripts in iPython Notebook. When I try to import bigfloat here, it says 'module not found.'

I have installed other packages such as SciPy, and using print scipy.file I see that it is located at //anaconda/lib/python2.7/site-packages/scipy/init.pyc

I'm not sure of how to check where bigfloat is located. From reading other peoples' installation issues, I am thinking that there might be more than one version of Python on my computer, and that is the problem? If this is the case, I'm not sure how to 1). Find the 'other' Python and delete it and 2). Make sure that future installations always install in the correct place (because I don't know where this is).

I've included my sys.path and error:

import sys
sys.path

['',
'//anaconda/python.app/Contents/lib/python27.zip',
'//anaconda/python.app/Contents/lib/python2.7',
'//anaconda/python.app/Contents/lib/python2.7/plat-darwin', 
'//anaconda/python.app/Contents/lib/python2.7/plat-mac',
'//anaconda/python.app/Contents/lib/python2.7/plat-mac/lib-scriptpackages',
'//anaconda/python.app/Contents/lib/python2.7/lib-tk',
'//anaconda/python.app/Contents/lib/python2.7/lib-old',       
'//anaconda/python.app/Contents/lib/python2.7/lib-dynload',
'//anaconda/lib/python2.7/site-packages',
'//anaconda/lib/python2.7/site-packages/PIL',
'//anaconda/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'//anaconda/lib/python2.7/site-packages/IPython/extensions']

import numpy as np
import scipy
from scipy.special import gamma, gammainc
import scipy.optimize as scopt
print scipy.__file__
import sympy
print sympy.__file__
import bigfloat
import sympy.mpmath as mpmath
from __future__ import division

ImportError Traceback (most recent call last) in () 6 import sympy 7 print sympy.file ----> 8 import bigfloat 9 import sympy.mpmath as mpmath 10 from future import division

ImportError: No module named bigfloat

//anaconda/lib/python2.7/site-packages/scipy/init.pyc //anaconda/lib/python2.7/site-packages/sympy/init.pyc


回答1:


I figured it out, mainly from using this question/answer.

Basically, I added both my "anaconda paths" and my "python paths" to my sys.path, using:

sys.path =['', etc.].



来源:https://stackoverflow.com/questions/26599443/module-successfully-installed-but-not-found-in-ipython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!