2016-01-24 266 views
3

我正在運行iPhyton筆記本,並且正在嘗試導入Seaborn軟件包。當我嘗試從終端導入它時,它加載得很好,但是當我通過iPython筆記本導入時,它給我出現以下錯誤。 我甚至試圖在iPython筆記本電腦中使用Conda和Pip來重新安裝Seaborn,但它仍然無法工作。 任何想法爲什麼?Python - 無法導入Seaborn

謝謝。

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 

enter image description here enter image description here

+0

你安裝了ipytho與conda?您可能必須執行'conda install notebook'來確保ipython可以看到您的庫。 – cel

+0

試過了,它不會工作。還是一樣的錯誤。 – jmich738

+0

然後請添加'which -a pip','which-python'和'which -a ipython'的輸出結果 – cel

回答

0

Donit所有系統上安裝的IPython。只在你想要的環境中安裝它。否則,Ipython將在默認路徑而不是環境路徑中查找模塊。

這可能是您的IPython的期待:

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

這裏要尋找模塊:

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

檢查路徑鍵入:

import sys 
sys.path 
1

嘗試這

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

import seaborn 

在我的Ubuntu 14.4LTS軟件包得到安裝在以下文件夾

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

所以我只是在運行時添加的包路徑

0

嘗試進入終端如下:

conda install seaborn 

它會安裝seaborn,並使其可用於您導入到您的筆記本