我有一个bIg数据平台。我在上面安装了Anaconda。当我在平台上ssh到我的账户,并在终端中打开Python解释器时,当我导入gensim库时,它工作得很好。我之前使用以下命令安装了这个库
Conda install gensim
$ python
Python 2.7.12 |Anaconda 2.5.0 (64-bit)| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import gensim
/home/anaconda2/lib/python2.7/site-packages/gensim/utils.py:1015: UserWarning: Pattern library is not installed, lemmatization won't be available.
warnings.warn("Pattern library is not installed, lemmatization won't be available.")如果您看到它确实导入了库(只是给出了模式库的一些警告)。但是,当我打开Jupyter notebook并尝试导入相同的库时,它会显示以下信息:
In [11]:
import gensim
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-11-0539d76422c6> in <module>()
----> 1 import gensim
ImportError: No module named gensim我不确定为什么安装的相同的库在Jupyter中不能工作。请注意,当我这样做的时候
pip list它向我展示了所有的库,并且在那里有gensim。
发布于 2017-12-08 06:53:23
pip list不会向您显示conda模块尝试conda list以确保您已安装gensim模块
编辑:
还要确保内核规范和python解释器指向相同的环境。
http://jupyter-client.readthedocs.io/en/stable/api/kernelspec.html
发布于 2018-09-23 11:54:26
这个问题很老了,但是自从google把我放在这里,对于其他人来说,我不得不为conda环境安装jupyter,因为它也是全局安装的,看不到我的env包。
发布于 2016-12-26 04:44:39
您可能正在使用不同的Python解释器运行Jupyter。查看notebook中打印的内容:
import sys
sys.path列出的目录与您在终端中启动Python时看到的目录相似还是不同?
https://stackoverflow.com/questions/41273573
复制相似问题