0

I am having problem while running this code in Windows10

word2vec = gensim.models.Word2Vec.load("word2vec.gensim")

and getting this error

word2vec = gensim.models.Word2Vec.load("word2vec.gensim")
Traceback (most recent call last):
File "<ipython-input-2-4557a9b0bbb0>", line 1, in <module>
word2vec = gensim.models.Word2Vec.load("word2vec.gensim")

File "C:\Users\abhis\Anaconda3\lib\site-packages\gensim\models\word2vec.py", 
line 1312, in load
model = super(Word2Vec, cls).load(*args, **kwargs)

File "C:\Users\abhis\Anaconda3\lib\site- 
packages\gensim\models\base_any2vec.py", line 1244, in load
model = super(BaseWordEmbeddingsModel, cls).load(*args, **kwargs)

File "C:\Users\abhis\Anaconda3\lib\site-
packages\gensim\models\base_any2vec.py", line 603, in load
return super(BaseAny2VecModel, cls).load(fname_or_handle, **kwargs)

File "C:\Users\abhis\Anaconda3\lib\site-packages\gensim\utils.py", line 422, 
in load
obj = unpickle(fname)

File "C:\Users\abhis\Anaconda3\lib\site-packages\gensim\utils.py", line 
1358, in unpickle
with smart_open(fname, 'rb') as f:

File "C:\Users\abhis\Anaconda3\lib\site- 
packages\smart_open\smart_open_lib.py", line 181, in smart_open
fobj = _shortcut_open(uri, mode, **kw)

File "C:\Users\abhis\Anaconda3\lib\site- 
packages\smart_open\smart_open_lib.py", line 301, in _shortcut_open
return open(parsed_uri.uri_path, mode, buffering=buffering, **open_kwargs)

FileNotFoundError: [Errno 2] No such file or directory: 'word2vec.gensim'
gojomo
  • 52,260
  • 14
  • 86
  • 115

1 Answers1

0

A FileNotFoundError means the file isn't where you've specified.

To find out the current working directory at the point where your code is executing, try:

import os
cwd = os.getcwd()
print(cwd)

Is your word2vec.gensim file in that directory? If not, specify how to get to it as an absolute full path (starting with C:\) or with a path relative to the working-directory (ascending into parent directories or descending into subdirectories as necessary).

gojomo
  • 52,260
  • 14
  • 86
  • 115
  • I have run your given code and its not show up anything in the working directory. – Abhishek Singh Oct 07 '18 at 14:37
  • If your `word2vec.gensim` file isn't in the working-directory, either move it to there, or specify its actual location as a full absolute path, or specify its location as a relative path from the working directory. – gojomo Oct 08 '18 at 00:37