ModuleNotFoundError: No module named 'gensim.summarization'; 'gensim' is not a package

4,059 views
Skip to first unread message

Rahul Gupta

unread,
Aug 27, 2019, 5:46:49 AM8/27/19
to Gensim
Hi!

I keep getting 'ModuleNotFoundError: No module named 'gensim.summarization'; 'gensim' is not a package', no matter what if I am using conda, pycharm.
I am using python 3.7.

Does gensim works on latest python version, does someone else face this error?

I am doing POC for my product and need help. Thanks!

Regards,
Rahul Gupta

Radim Řehůřek

unread,
Aug 27, 2019, 8:31:36 AM8/27/19
to Gensim
How did you install Gensim and how exactly are you using it?

-rr

Rahul Gupta

unread,
Aug 29, 2019, 6:41:38 AM8/29/19
to Gensim
I have created a conda env with latest version of miniconda & python.

I have installed gensim using:
conda install -c conda-forge gensim

When I run below on python promt from my conda env, it works.
from gensim.summarization import summarize

However, if I run above as a part of .py script from my conda env, it gives me modulenotfound error.

I am not sure what I am missing. Any help would be appreciated. Thanks!

Radim Řehůřek

unread,
Aug 30, 2019, 6:11:27 AM8/30/19
to Gensim
My guess is you're using a different python installation for the a) your command prompt vs b) your script.

Make sure you're using the same python installation in both. You can inspect with e.g. `which python` from shell, or with `print(sys.executable)` from Python.

HTH,
Radim

Rahul Gupta

unread,
Aug 30, 2019, 6:57:35 AM8/30/19
to Gensim
Both places it print same python and i.e. below:

/home/rahul/miniconda3/envs/gensim/bin/python


And also gensim is available under site-packages.

Radim Řehůřek

unread,
Aug 30, 2019, 5:14:29 PM8/30/19
to Gensim
That's weird. What's the full stack trace?

-rr

hans mohan

unread,
Aug 31, 2019, 1:35:00 AM8/31/19
to gen...@googlegroups.com
Hi Radim,

Although my input shall be of not of much use. But the official Gensim documentation says :
image.png

Rahul mentions he uses python 3.7 version. By any-chance it has got something to do with the error.

Thanks and regards,
Hans Mohan


--
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gensim/ea8464b7-e402-47ae-8691-77ede0eb7c9b%40googlegroups.com.

Arshad Shaik

unread,
Aug 31, 2019, 1:43:39 PM8/31/19
to gen...@googlegroups.com
Hi,

This might be the issue related to pycharm, I remember getting similar issues while using pycharm. I would recommend doing below two things:
1. instead of running the .py script from pycharm run it from command prompt while your virtual environment is active(this should work)
2. Try uninstalling and installing pycharm back again and test it.(this confirms issue with pycharm and you can get more details on pycharm forums on this issue)

Thanks,
Arshad Shaik

--
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+un...@googlegroups.com.

Rahul Gupta

unread,
Sep 1, 2019, 6:42:00 AM9/1/19
to Gensim
It worked.
I have recreated the conda env from within pycharm. (it did it in reverse order previously)
I realized that the correct conda env was not activated when I was running it from inside earlier.

Thank you, all!!

Rahul
To unsubscribe from this group and stop receiving emails from it, send an email to gen...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages