[英]Python3.6 - Cannot import gensim in Windows
I use Python 3.6.3rc1.我使用 Python 3.6.3rc1。 I get following message after executing my python script:
执行我的 python 脚本后,我收到以下消息:
Traceback (most recent call last):
File "main.py", line 6, in <module>
from train import train
File "C:\path\train.py", line 2, in <module>
import dataUtils
File "C:\path\dataUtils.py", line 5, in <module>
import gensim
ImportError: No module named gensim
But gensim is already installed.但是已经安装了gensim。 Command
pip3 freeze
gives following list:命令
pip3 freeze
给出以下列表:
bleach==1.5.0
boto==2.48.0
bz2file==0.98
certifi==2017.7.27.1
chardet==3.0.4
gensim==3.0.1
html5lib==0.9999999
idna==2.6
jieba==0.39
Markdown==2.6.9
numpy==1.13.3+mkl
protobuf==3.4.0
requests==2.18.4
scipy==0.19.1
six==1.11.0
smart-open==1.5.3
tensorflow==1.3.0
tensorflow-tensorboard==0.1.7
urllib3==1.22
Werkzeug==0.12.2
When I imported KeyedVectors from gensim.models ( from gensim.models import KeyedVectors
) in another script, it worked.当我在另一个脚本中从 gensim.models (
from gensim.models import KeyedVectors
) from gensim.models import KeyedVectors
,它起作用了。
Any suggestions?有什么建议?
Thanks for any reply.感谢您的任何答复。
this might be caused by pip3
using another python executable than your script.这可能是由
pip3
使用另一个 python 可执行文件而不是您的脚本引起的。
try debugging by inserting a import sys; print(sys.path)
通过插入
import sys; print(sys.path)
尝试调试import sys; print(sys.path)
import sys; print(sys.path)
and check if it contains any of your pip3
paths... import sys; print(sys.path)
并检查它是否包含您的任何pip3
路径...
Solved.解决了。
I removed following line at the beginning of executable file and it solved problem.我删除了可执行文件开头的以下行并解决了问题。
#!/usr/bin/python
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.