Home:ALL Converter>gensim error: ImportError: No module named 'gensim'

gensim error: ImportError: No module named 'gensim'

Ask Time:2017-09-12T13:33:26         Author:woojung

Json Formatter

I trying to import gensim with

import gensim

but get 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.

Author:woojung,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46168600/gensim-error-importerror-no-module-named-gensim
hexicle :

If using Python3 be sure to use pip3 instead of pip for installing gensim. ",
2018-07-12T21:04:30
luky :

i had this error because i ran "python" not "python3" i always do this from time to time.",
2021-04-17T13:18:05
vinsinraw :

On Jupyter notebook, following worked for me\n\n!python -m pip install -U gensim\n\n\nAlternatively, run Anaconda prompt as administrator and execute the following\n\n(base) C:\\Windows\\system32>conda install -c conda-forge gensim\n",
2020-01-01T20:14:11
oklm :

If you are using a virtual environment, check if gensim is installed with the following command:pip list.\nIf it is not installed then install it: pip install -U gensim or pip install gensim.\nAlso if you are using Jupyter notebook, verify if gensim is install in the python kernel you are using.",
2021-05-08T14:58:50
Nikhil Nair :

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.",
2019-08-19T16:33:43
lakchchayam divya Khare :

The mirror link is slow guyz.\nTry it manually\nDownload the gensim file from https://pypi.org/project/gensim/#files\nand extract it by Winrar then go inside the folder type python setup.py install\nit was success for me",
2021-07-26T12:31:36
mAge :

My solution is for Windows 10, Anaconda. Where I want to use gensim with Spyder.\n\nSolution: 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)\n\nScree shot of Anaconda Navigator\n\n\nRepeat above for word2vec\n\n\nHistory: 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.\n\n\nBonus: Same is true for tensorflow\n",
2019-07-13T05:58:42
INDRAJITH EKANAYAKE :

If you are trying to install genism for the Jupyter notebook and all the above answers are not working, try installing genism using conda-forge channel\nconda install -c conda-forge genism\n\nHere I use the -c flag to give the channel name. If channels are new to you I would like to refer you to this question on Stackoverflow",
2021-11-21T09:42:07
Manh Quang Do :

import model gensim python3x:\n\npip install gensim\n",
2020-05-25T11:09:37
Sigmund :

If you have an anaconda environment running, try deactivating that and installing gensim again.\nAfter doing it that way I was able to import it in jupyter notebook.",
2022-05-01T20:55:41
Ayush Jain :

As mentioned by @Burhan Khalid in the comments, don't name your file gensim.py as it will look in local folder first for gensim and consider it as what you are trying to import. \n\nPS: I wrote this here as people tend to skip the comments. If it helped, please upvote the original comment.",
2019-06-20T04:45:22
Asad Syed :

first, you have to run the command !pip install gensim==3.6.0\nthen run these commands\nfrom gensim.models import KeyedVectors\n\nfrom gensim.models import word2vec\n\nmodel = KeyedVectors.load_word2vec_format('./model/GoogleNews- \nvectors-negative300.bin', binary=True)\n",
2022-08-16T15:15:21
Aus_10 :

To Tanu's point, first guess would be you're not in the correct directory. Below is the first thing I would check. \n\nimport sys, os\n# */site-packages is where your current session is running its python out of\nsite_path = ''\nfor path in sys.path:\n if 'site-packages' in path.split('/')[-1]:\n print(path)\n site_path = path\n# search to see if gensim in installed packages\nif len(site_path) > 0:\n if not 'gensim' in os.listdir(site_path):\n print('package not found')\n else:\n print('gensim installed') \n",
2017-12-12T04:16:53
Lavanya U :

reinstalling the python,I was able to solve this issue",
2022-09-19T07:33:59
Max :

Does 'gensim' appear in the packages shown by the command pip freeze? If not, you may not have activated the 'environment' with the necessary packages, in your working shell/IDE.",
2017-09-12T05:43:12
Tanu :

Install gensim using:\n\npip install -U gensim\n\n\nOr, if you have instead downloaded and unzipped the source tar.gz package, then run:\n\npython setup.py test\npython setup.py install\n",
2017-09-12T05:42:10
Grant Shannon :

Using pip inside Anaconda command prompt worked for me:\n(base) C:\\Users\\ABC>pip install -U gensim\n",
2020-07-21T11:13:44
yy