Reputation: 37
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
Upvotes: 0
Views: 2123
Reputation: 8418
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.
Upvotes: 1
Reputation: 37
I solved the problem by reinstalling the library on a virtual environment using virtualenv as described here: http://docs.python-guide.org/en/latest/dev/virtualenvs/
Upvotes: 0
Reputation: 3
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.
Upvotes: 0