【发布时间】:2017-10-17 14:27:53
【问题描述】:
我可以在从 bash 运行 python 或 ipython 时导入 nltk 包。所以,nltk 肯定安装在 somewhere (在 python 中来自 bash,
nltk.__file__ 是
/home/nadine/anaconda2/lib/python2.7/site-packages/nltk/__init__.pyc)
但是,当使用 Jupyter Notebook(我使用 Anaconda 安装的,带有 2.7 版本的 python)时,导入 nltk 失败:
import nltk
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-b06499430ee0> in <module>()
----> 1 import nltk
ImportError: No module named nltk
在 Jupyter Notebook 中,sys.executable 产生 /home/nadine/.conda/envs/py27/bin/python,而在 bash 中的 python 中,它产生 /home/nadine/anaconda2/bin/python2.7
这里到底出了什么问题,我该如何解决?
【问题讨论】:
标签: python import ipython nltk jupyter-notebook