[Solved]: ModuleNotFoundError: No module named 'gensim'

Problem: gensim error : no module named gensim

I am trying to import gensim. I have the following code

from nltk.stem.porter import PorterStemmerfrom nltk.corpus import stopwordsfrom nltk.tokenize import RegexpTokenizerfrom gensim import corpora, modelsimport wikipediaimport gensim

I got the following error.

---------------------------------------------------------------------------ModuleNotFoundError                       Traceback (most recent call last) in ()      2 from nltk.corpus import stopwords      3 from nltk.tokenize import RegexpTokenizer----> 4 from gensim import corpora, models      5 import wikipedia      6 import gensimModuleNotFoundError: No module named 'gensim'


Solution:

Install gensim using:

pip install -U gensim

Or, if you have instead downloaded and unzipped the source tar.gz package, then run:

python setup.py testpython setup.py install

Note:  If using Python3 be sure to use pip3 instead of pip for installing gensim.