[英]gensim installed in anaconda env but won't import in jupyter notebook
I'm trying to install gensim in a specific conda env on my Python 3 only, Windows 10 machine. 我正在尝试在仅Python 3 Windows 10机器上的特定conda env中安装gensim。 I've tried 3 different ways based on suggestions in SO and elsewhere, summarized below.
我根据SO和其他地方的建议尝试了3种不同的方式,总结如下。 Each time it shows as successfully installed and present in the env, but when I try to import it in jupyter notebook I get the
ModuleNotFoundError: No module named 'gensim'
error. 每次显示为已成功安装并存在于环境中,但是当我尝试将其导入jupyter笔记本电脑时,我收到
ModuleNotFoundError: No module named 'gensim'
错误。
Note: I closed and relaunched anaconda and jupyter after each install. 注意:每次安装后,我关闭并重新启动anaconda和jupyter。
SUMMARY: 3 attempts with 3 install commands: 摘要:使用3个安装命令进行3次尝试:
COMMAND CONDA LIST IMPORT IN JUPYTER NOTEBOOK
conda install -c anaconda gensim gensim 3.4.0 py36hfa6e2cd_0 anaconda ModuleNotFoundError: No module named 'gensim'
pip install -U gensim gensim 3.7.3 pypi_0 pypi ModuleNotFoundError: No module named 'gensim'
conda install -c conda-forge gensim gensim 3.7.3 py36h6538335_0 conda-forge ModuleNotFoundError: No module named 'gensim'
(base) C:\Users\kb>conda activate SARC
(SARC) C:\Users\kb>conda install -c anaconda gensim
(SARC) C:\Users\kb>conda list
. . .
gensim 3.4.0 py36hfa6e2cd_0 anaconda
. . .
. . .
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e92e291fb8cb> in <module>
1 import loader
2 import reader
----> 3 import transformers
4 import vectorization
~\OneDrive\Documents\ds\courses_books\Applied_Text_Analysis_Python_book_code\atap-master\snippets\ch04\transformers.py in <module>
3 import os
4 import nltk
----> 5 import gensim
6 import unicodedata
7
ModuleNotFoundError: No module named 'gensim'
Details of the install commands and output can be seen here . 安装命令和输出的详细信息可以在这里看到。
Per our discussion in the comments, when you launch via jupyter
directly, it seems you're using some other (perhaps system-wide) Python interpreter & environment – one which doesn't have gensim
installed – even though you've "activated" your SARC
environment. 根据我们在评论中的讨论,当您直接通过
jupyter
启动时,似乎您正在使用其他(也许是系统范围内的)Python解释器和环境-尽管尚未激活gensim
,但尚未安装gensim
您的SARC
环境。 (Essentially, "activating" an environment tries to alias python
& some other things to use the right enviroment, but other commands might still reach out to some other Python installation.) (本质上,“激活”环境会尝试为
python
及其他一些东西加上别名,以使用正确的环境,但其他命令可能仍可用于其他Python安装。)
Per @furas' suggestion of using python -m jupyter notebook
, you'll be sure to invoke plain python
, and thus the SARC
environment – and thus test whether gensim
and/or jupyter
are even really installed inside the SARC
environment. 根据@furas关于使用
python -m jupyter notebook
的建议,您一定要调用纯python
,从而调用SARC
环境-并测试gensim
和/或jupyter
是否真的安装在SARC
环境中。
If not, be sure to install them there, and make sure any interpreters/notebooks you launch truly use the intended environment. 如果没有,请确保将其安装在此处,并确保您启动的所有口译员/笔记本电脑都真正使用了预期的环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.