Python - Can't import Seaborn

最后都变了- 提交于 2021-02-06 13:54:01

问题


I'm running iPhyton Notebooks and I'm trying to import the Seaborn package. When I try to import it from the Terminal, it loads up fine, but when I import it through iPython Notebooks, it give me the following error. I have even tried to re-install Seaborn using both Conda and Pip inside iPython notebooks and still it wont work. Any idea why?

Thanks.

ImportError                               Traceback (most recent call last)
<ipython-input-1-417274a1ae6c> in <module>()
      1 get_ipython().system(u'conda install seaborn')
      2 get_ipython().system(u'pip install seaborn')
----> 3 import seaborn as sb
      4 

ImportError: No module named seaborn


回答1:


Try this

import sys
print sys.path
sys.path.append('<path to package in your syste>')

import seaborn

In my Ubuntu 14.4LTS the packages get installed in the following folder

/usr/local/lib/python2.7/dist-packages

So I simply add the package path at run time




回答2:


Donit install Ipython on all your system. Install it only in the environments you want it. Otherwise Ipython will look for modules in the default path instead of the environment's path.

This is probably where your ipython is looking:

/home/user/anaconda2/lib/python2.7/

It should be looking for modules here:

/home/user/anaconda2/envs/name-of-env/lib/python3.4/

To check the path you type:

import sys
sys.path



回答3:


Try entering the following in your terminal:

conda install seaborn

It will install seaborn and make it available for you to import into your notebook




回答4:


Open anaconda prompt and Type

pip install seaborn


来源:https://stackoverflow.com/questions/34973997/python-cant-import-seaborn

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