简体   繁体   中英

importing gensim in mac

I'm having a problem when trying to import gensim in python. When typing:

import gensim

I got the following error:

Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.7/site-packages/gensim/ init .py", line 6, in from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization ImportError: cannot import name parsing

Also, when I view " init .py" it contains only the following lines:

bring model classes directly into package namespace, to save some typing

from .summarizer import summarize, summarize_corpus

from .keywords import keywords

Any idea on how to solve this problem is highly appreciated.

I'm using: MAC 10.10.5 and Python 2.7

Thank you

I had a similar error. I used pip to update itself, then uninstall, reinstall, and update gensim. I also pip installed Theano (b/c mine was unable to import something related to it).

pip install --upgrade pip
pip uninstall gensim
pip install --upgrade gensim 
pip install Theano 

Then I needed to close and restart a new terminal python shell, and it worked!

One other note-- if you look at the error message, you can see the filepath to the .py files in the /gensim folder and the line in that .py file causing the error. Then you can try to manually run each import that is causing an error (after cd-ing to the appropriate folder). This might help you find what packages are causing the problem.

The file "init.py" is trying to import things from gensim.py. It's unable to import one of the classes. As you can see in the last line of your error, it says it was unable to import name parsing. I suggest: -if you downloaded the package from the internet(I'm quite new to python, and still don't know all the downloadable content): -Search the website for what this package means and try redownloading it (re-install the module). Also, try looking after if the versions are compatible. If this package have many versions, find the appropriate version according to your python version.

What happens is that part of the package is missing.

我通过使用virtualenv在虚拟环境中重新安装该库解决了该问题,如下所述: http : //docs.python-guide.org/en/latest/dev/virtualenvs/

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