Open azureskyL opened 7 years ago
pip install gensim
I have the same problem when trying to import Word2Vec
if you are using Jupyter notebook then you can try conda install gensim, that worked for me. Try using pip3 install gensim that works too
sudo pip3 install -U gensim Worked on my: Ubuntu 16.04 64 bit python3.5 Jupyter Notebook
One thing to note is this: if you run jupyter notebook
from the Anaconda command prompt/terminal, then make sure you have an environment-specific jupyter notebook version! Otherwise, it will use the global notebook, and it won't have the environmental packages you want.
getting same error in windows also , conda install gensim is not working bro!
Yes its not :(
Try writing conda install -c anaconda gensim in the command prompt and then continue in the jupyter notebook.
It is 2019. I am facing the same issue.
I'm having the issue right now. I installed gensim in my conda env in 3 different ways, including using conda install -c anaconda gensim
. Each time it shows as successfully installed and present in the env, but when I try to import it in jupyter notebook I get the ModuleNotFoundError: No module named 'gensim'
error.
SUMMARY: 3 attempts with 3 install commands:
COMMAND CONDA LIST IMPORT IN JUPYTER NOTEBOOK
conda install -c anaconda gensim gensim 3.4.0 py36hfa6e2cd_0 anaconda ModuleNotFoundError: No module named 'gensim'
pip install -U gensim gensim 3.7.3 pypi_0 pypi ModuleNotFoundError: No module named 'gensim'
conda install -c conda-forge gensim gensim 3.7.3 py36h6538335_0 conda-forge ModuleNotFoundError: No module named 'gensim'
DETAILS:
Installation input/output and error below:
INSTALL GENSIM IN SARC env
(base) C:\Users\karls>conda activate SARC
(SARC) C:\Users\karls>conda install -c anaconda gensim
Collecting package metadata: done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.6.14
latest version: 4.7.5
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: C:\Users\karls\Anaconda3\envs\SARC
added / updated specs:
- gensim
The following packages will be downloaded:
package | build
---------------------------|-----------------
asn1crypto-0.24.0 | py36_0 155 KB anaconda
boto-2.49.0 | py36_0 1.6 MB anaconda
boto3-1.9.162 | py_0 88 KB anaconda
botocore-1.12.163 | py_0 3.3 MB anaconda
bz2file-0.98 | py36_1 13 KB anaconda
ca-certificates-2019.5.15 | 0 166 KB anaconda
certifi-2019.6.16 | py36_0 155 KB anaconda
cffi-1.12.3 | py36h7a1dbc1_0 225 KB anaconda
chardet-3.0.4 | py36_1 210 KB anaconda
cryptography-2.7 | py36h7a1dbc1_0 564 KB anaconda
docutils-0.14 | py36h6012d8f_0 695 KB anaconda
gensim-3.4.0 | py36hfa6e2cd_0 21.4 MB anaconda
idna-2.8 | py36_0 134 KB anaconda
jmespath-0.9.4 | py_0 22 KB anaconda
openssl-1.1.1 | he774522_0 5.7 MB anaconda
pycparser-2.19 | py36_0 174 KB anaconda
pyopenssl-19.0.0 | py36_0 82 KB anaconda
pysocks-1.7.0 | py36_0 30 KB anaconda
requests-2.22.0 | py36_0 90 KB anaconda
s3transfer-0.2.0 | py36_0 93 KB anaconda
smart_open-1.8.4 | py_0 55 KB anaconda
urllib3-1.24.2 | py36_0 153 KB anaconda
vc-14.1 | h21ff451_3 5 KB anaconda
vs2015_runtime-15.5.2 | 3 2.2 MB anaconda
win_inet_pton-1.1.0 | py36_0 9 KB anaconda
------------------------------------------------------------
Total: 37.3 MB
The following NEW packages will be INSTALLED:
asn1crypto anaconda/win-64::asn1crypto-0.24.0-py36_0
boto anaconda/win-64::boto-2.49.0-py36_0
boto3 anaconda/noarch::boto3-1.9.162-py_0
botocore anaconda/noarch::botocore-1.12.163-py_0
bz2file anaconda/win-64::bz2file-0.98-py36_1
cffi anaconda/win-64::cffi-1.12.3-py36h7a1dbc1_0
chardet anaconda/win-64::chardet-3.0.4-py36_1
cryptography anaconda/win-64::cryptography-2.7-py36h7a1dbc1_0
docutils anaconda/win-64::docutils-0.14-py36h6012d8f_0
gensim anaconda/win-64::gensim-3.4.0-py36hfa6e2cd_0
idna anaconda/win-64::idna-2.8-py36_0
jmespath anaconda/noarch::jmespath-0.9.4-py_0
pycparser anaconda/win-64::pycparser-2.19-py36_0
pyopenssl anaconda/win-64::pyopenssl-19.0.0-py36_0
pysocks anaconda/win-64::pysocks-1.7.0-py36_0
requests anaconda/win-64::requests-2.22.0-py36_0
s3transfer anaconda/win-64::s3transfer-0.2.0-py36_0
smart_open anaconda/noarch::smart_open-1.8.4-py_0
urllib3 anaconda/win-64::urllib3-1.24.2-py36_0
win_inet_pton anaconda/win-64::win_inet_pton-1.1.0-py36_0
The following packages will be UPDATED:
certifi pkgs/main::certifi-2019.3.9-py36_0 --> anaconda::certifi-2019.6.16-py36_0
openssl pkgs/main::openssl-1.1.1c-he774522_1 --> anaconda::openssl-1.1.1-he774522_0
vs2015_runtime pkgs/main::vs2015_runtime-14.15.26706~ --> anaconda::vs2015_runtime-15.5.2-3
The following packages will be SUPERSEDED by a higher-priority channel:
ca-certificates pkgs/main --> anaconda
vc pkgs/main::vc-14.1-h0510ff6_4 --> anaconda::vc-14.1-h21ff451_3
Proceed ([y]/n)? y
Downloading and Extracting Packages
bz2file-0.98 | 13 KB | ############################################################################ | 100%
chardet-3.0.4 | 210 KB | ############################################################################ | 100%
pyopenssl-19.0.0 | 82 KB | ############################################################################ | 100%
gensim-3.4.0 | 21.4 MB | ############################################################################ | 100%
pycparser-2.19 | 174 KB | ############################################################################ | 100%
vc-14.1 | 5 KB | ############################################################################ | 100%
cryptography-2.7 | 564 KB | ############################################################################ | 100%
idna-2.8 | 134 KB | ############################################################################ | 100%
urllib3-1.24.2 | 153 KB | ############################################################################ | 100%
win_inet_pton-1.1.0 | 9 KB | ############################################################################ | 100%
boto-2.49.0 | 1.6 MB | ############################################################################ | 100%
pysocks-1.7.0 | 30 KB | ############################################################################ | 100%
cffi-1.12.3 | 225 KB | ############################################################################ | 100%
ca-certificates-2019 | 166 KB | ############################################################################ | 100%
botocore-1.12.163 | 3.3 MB | ############################################################################ | 100%
asn1crypto-0.24.0 | 155 KB | ############################################################################ | 100%
openssl-1.1.1 | 5.7 MB | ############################################################################ | 100%
requests-2.22.0 | 90 KB | ############################################################################ | 100%
vs2015_runtime-15.5. | 2.2 MB | ############################################################################ | 100%
docutils-0.14 | 695 KB | ############################################################################ | 100%
smart_open-1.8.4 | 55 KB | ############################################################################ | 100%
s3transfer-0.2.0 | 93 KB | ############################################################################ | 100%
certifi-2019.6.16 | 155 KB | ############################################################################ | 100%
boto3-1.9.162 | 88 KB | ############################################################################ | 100%
jmespath-0.9.4 | 22 KB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(SARC) C:\Users\karls>
conda list shows that gensim is installed:
(base) C:\Users\karls>conda activate SARC
(SARC) C:\Users\karls>conda list
# packages in environment at C:\Users\karls\Anaconda3\envs\SARC:
#
# Name Version Build Channel
_tflow_select 2.3.0 mkl
absl-py 0.7.1 py36_0
asn1crypto 0.24.0 py36_0 anaconda
astor 0.7.1 py36_0
blas 1.0 mkl
boto 2.49.0 py36_0 anaconda
boto3 1.9.162 py_0 anaconda
botocore 1.12.163 py_0 anaconda
bz2file 0.98 py36_1 anaconda
ca-certificates 2019.5.15 0 anaconda
certifi 2019.6.16 py36_0 anaconda
cffi 1.12.3 py36h7a1dbc1_0 anaconda
chardet 3.0.4 py36_1 anaconda
cryptography 2.7 py36h7a1dbc1_0 anaconda
docutils 0.14 py36h6012d8f_0 anaconda
gast 0.2.2 py36_0
gensim 3.4.0 py36hfa6e2cd_0 anaconda
grpcio 1.16.1 py36h351948d_1
h5py 2.9.0 py36h5e291fa_0
hdf5 1.10.4 h7ebc959_0
icc_rt 2019.0.0 h0cc432a_1
idna 2.8 py36_0 anaconda
intel-openmp 2019.4 245
jmespath 0.9.4 py_0 anaconda
keras 2.2.4 0
keras-applications 1.0.8 py_0
keras-base 2.2.4 py36_0
keras-preprocessing 1.1.0 py_1
libmklml 2019.0.3 0
libprotobuf 3.8.0 h7bd577a_0
markdown 3.1.1 py36_0
mkl 2019.4 245
mkl_fft 1.0.12 py36h14836fe_0
mkl_random 1.0.2 py36h343c172_0
mock 3.0.5 py36_0
nltk 3.4.1 py36_0
numpy 1.16.4 py36h19fb1c0_0
numpy-base 1.16.4 py36hc3f5095_0
openssl 1.1.1 he774522_0 anaconda
pandas 0.24.2 py36ha925a31_0
pip 19.1.1 py36_0
protobuf 3.8.0 py36h33f27b4_0
pycparser 2.19 py36_0 anaconda
pyopenssl 19.0.0 py36_0 anaconda
pyreadline 2.1 py36_1
pysocks 1.7.0 py36_0 anaconda
python 3.6.8 h9f7ef89_7
python-dateutil 2.8.0 py36_0
pytz 2019.1 py_0
pyyaml 5.1 py36he774522_0
requests 2.22.0 py36_0 anaconda
s3transfer 0.2.0 py36_0 anaconda
scipy 1.2.1 py36h29ff71c_0
setuptools 41.0.1 py36_0
six 1.12.0 py36_0
smart_open 1.8.4 py_0 anaconda
sqlite 3.28.0 he774522_0
tensorboard 1.13.1 py36h33f27b4_0
tensorflow 1.13.1 mkl_py36hd212fbe_0
tensorflow-base 1.13.1 mkl_py36hcaf7020_0
tensorflow-estimator 1.13.0 py_0
termcolor 1.1.0 py36_1
urllib3 1.24.2 py36_0 anaconda
vc 14.1 h21ff451_3 anaconda
vs2015_runtime 15.5.2 3 anaconda
werkzeug 0.15.4 py_0
wheel 0.33.4 py36_0
win_inet_pton 1.1.0 py36_0 anaconda
wincertstore 0.2 py36h7fe50ca_0
yaml 0.1.7 hc54c509_2
zlib 1.2.11 h62dcd97_3
But when I try to import gensim in a jupyter notebook in the evironment I get a ModuleNotFoundError: No module named 'gensim'
error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-e92e291fb8cb> in <module>
1 import loader
2 import reader
----> 3 import transformers
4 import vectorization
~\OneDrive\Documents\ds\courses_books\Applied_Text_Analysis_Python_book_code\atap-master\snippets\ch04\transformers.py in <module>
3 import os
4 import nltk
----> 5 import gensim
6 import unicodedata
7
ModuleNotFoundError: No module named 'gensim'
I then tried pip install -U gensim
.
This replaced the gensim 3.4 installed by conda install -c anaconda gensim
with gensim 3.7 from pypi:
conda list
. . .
gensim 3.7.3 pypi_0 pypi
. . .
But still I get the error when I try to import
Have gone through similar steps like @karlwbaker but still no luck. :(
conda install -c conda-forge gensim
worked for me.
I solved the problem I was having (above). Gensim was fine. The problem was that I didn't have jupyter installed in the Anaconda env so it was using the version from the base install, which was for a later version of python. Installing jupyter in the env with gensim solved the problem.
Added note:
A practice I learned from the comments to my SO question on this issue is to launch jupyter notebook with python -m jupyter notebook
. Doing so seems to enforce a rule to only import modules that have been installed in the active env, rather than importing from the base env when the module does not exist in the active env. This makes explicit exactly which versions of libraries are being used. See https://stackoverflow.com/q/56910538/9677043 for further deets.
It is 2020. I tried all solutions above but still :(
I also face the same issue.
it is 2021 and still the same issue
It will be 2030, and same issue.
Edit, 20 min later:
pip3 install gensim==3.8.3
python -m jupyter notebook
That worked for me. Good luck.
"conda install -c conda-forge gensim" has solved my issue when I am trying to import word2vec
😂😂🤣🤣
It will be 2030, and same issue.
Edit, 20 min later:
- Downgrade,
pip3 install gensim==3.8.3
- If using jupyter, rerun with
python -m jupyter notebook
That worked for me. Good luck.
🤣🤣
Still facing same issue,
using pipenv virtual environment with python3.7.x
tried gensim 4.x and 3.x non worked, same error message
I have installed gensim with the command: conda install -c conda-forge gensim
But I am getting the error while importing the library gensim.viz
from gensim.viz.poincare import poincare_2d_visualization
The exact error is: ModuleNotFoundError: No module named 'gensim.viz'
How to resolve this issue?
That may be due to version error
when I try to run train.py, the error occurs: ljy@ubuntu:~/debug_seq2seq$ python bin/train.py Traceback (most recent call last): File "bin/train.py", line 9, in
from lib.w2v_model import w2v
File "/home/ljy/debug_seq2seq/lib/w2v_model/w2v.py", line 4, in
from gensim.models import Word2Vec
ImportError: No module named gensim.models
But I has just install gensim by using sudo easy_install -U gensim Anyone could help me ?