简体   繁体   中英

Python3.6 - Cannot import gensim in Windows

I use Python 3.6.3rc1. I get following message after executing my python script:

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. Command pip3 freeze gives following list:

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.

Any suggestions?

Thanks for any reply.

this might be caused by pip3 using another python executable than your script.

try debugging by inserting a import sys; print(sys.path) import sys; print(sys.path) and check if it contains any of your pip3 paths...

Solved.

I removed following line at the beginning of executable file and it solved problem.

#!/usr/bin/python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM