gensim error : no module named gensim

91,293

Solution 1

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 test
python setup.py install

Solution 2

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

Solution 3

On Jupyter notebook, following worked for me

!python -m pip install -U gensim

Alternatively, run Anaconda prompt as administrator and execute the following

(base) C:\Windows\system32>conda install -c conda-forge gensim

Solution 4

I did a pip install gensim --user and it worked. The problem I was having with conda install gensim and pip -U install gensim was that it was not able to modify the environment variable at the end of the install.

Solution 5

My solution is for Windows 10, Anaconda. Where I want to use gensim with Spyder.

Solution: Use Anaconda Navigator, and install package from there: Open Anaconda Navigator -> Environments (base) -> not installed (packages) -> (search for) gensim -> check the gensim option from the drop down list-> Press apply button -> (wait for a while, it will search other dependencies, then press the button one more time to install required package)

Scree shot of Anaconda Navigator

  • Repeat above for word2vec

History: On anaconda command prompt, using conda command, I installed gensim. Every thing looks perfect but it was even not imported, "import gensim", in command prompt.

  • Bonus: Same is true for tensorflow
Share:
91,293
woojung
Author by

woojung

Updated on November 21, 2021

Comments

  • woojung
    woojung over 2 years

    I trying to import gensim.

    I have the following code

    import gensim
    model = gensim.models.Word2Vec.load_word2vec_format('./model/GoogleNews-  
    vectors-negative300.bin', binary=True)  
    

    I got the following error.

    ImportError                               Traceback (most recent call  
    last)
    <ipython-input-5-50007be813d4> in <module>()
    ----> 1 import gensim
      2 model = gensim.models.Word2Vec.load_word2vec_format('./model  
    /GoogleNews-vectors-negative300.bin', binary=True)
    
    ImportError: No module named 'gensim'
    

    I installed gensim in python. I use genssim for word2vec.

  • woojung
    woojung over 6 years
    Gensim appears in package