Error if I try to import from gensim.models, as was in the original code.
Also error when I tried to import from gensim.keyedvectors based on the page below.
https://radimrehurek.com/gensim/models/keyedvectors.html
Thx much ...
@barryef could you show the error log please
What gensim version are you using?
Hi prakhar2b and tmylk,
My gensim version is 0.13
The traceback is below. The original code is line 14. I am now using lines 13 and 15 without apparent problem, so I have a workaround.
ImportError Traceback (most recent call last)
12
13 #from gensim.models import Word2Vec, keyedvectors # , KeyedVectors
---> 14 from gensim.models import Word2Vec, KeyedVectors
15 from gensim.models.keyedvectors import KeyedVectors
16 from gensim.models.word2vec import Text8Corpus
ImportError: cannot import name 'KeyedVectors'
Actually, workaround is not working futher along in the code.
The code asks for KeyedVectors.load_word2vec_format
I can't find this function in either
gensim.models.KeyedVectors or
gensim.models.keyedvectors.KeyedVectors.
Hey @barryef! The function KeyedVectors.load_word2vec_format has been defined in the file gensim.models.keyedvectors as a method of the class KeyedVectors. Could you please check again if you are looking in the correct file? If you still face an issue, I'd be happy to help further. :)
OK, I've found my solution. There's an updated version of the markroxor ipynb that only imports Word2Vec and runs without breaking at
https://markroxor.github.io/gensim/static/notebooks/Word2Vec_FastText_Comparison.html
Thanks for being around on the weekend ...
@barryef The 1.0.0 version of gensim contains KeyedVectors.load_word2vec_format. Is there a reason for using 0.13.x?
No. I used pip to install and assumed I had the most recent version. I’ll update.
Thx
From: Lev Konstantinovskiy notifications@github.com
Reply-To: RaRe-Technologies/gensim reply@reply.github.com
Date: Sunday, March 12, 2017 at 12:28 PM
To: RaRe-Technologies/gensim gensim@noreply.github.com
Cc: barryef bf@imci.us.com, Mention mention@noreply.github.com
Subject: Re: [RaRe-Technologies/gensim] cannot import KeyedVectors in Python 3.5 (#1204)
@barryef The 1.0.0 version of gensim contains KeyedVectors.load_word2vec_format. Is there a reason for using 0.13.x?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Are you using Anaconda? If yes, need to ping them to update.
Miniconda. I don’t know how to ping them.
From: Lev Konstantinovskiy notifications@github.com
Reply-To: RaRe-Technologies/gensim reply@reply.github.com
Date: Sunday, March 12, 2017 at 12:35 PM
To: RaRe-Technologies/gensim gensim@noreply.github.com
Cc: barryef bf@imci.us.com, Mention mention@noreply.github.com
Subject: Re: [RaRe-Technologies/gensim] cannot import KeyedVectors in Python 3.5 (#1204)
Are you using Anaconda? If yes, need to ping them to update.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Lev, I checked on pip, and pip install gensim is indeed at 0.13 but pip install –U gives gensim 1.01.
From: Lev Konstantinovskiy notifications@github.com
Reply-To: RaRe-Technologies/gensim reply@reply.github.com
Date: Sunday, March 12, 2017 at 12:35 PM
To: RaRe-Technologies/gensim gensim@noreply.github.com
Cc: barryef bf@imci.us.com, Mention mention@noreply.github.com
Subject: Re: [RaRe-Technologies/gensim] cannot import KeyedVectors in Python 3.5 (#1204)
Are you using Anaconda? If yes, need to ping them to update.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
Most helpful comment
Hey @barryef! The function
KeyedVectors.load_word2vec_formathas been defined in the file gensim.models.keyedvectors as a method of the classKeyedVectors. Could you please check again if you are looking in the correct file? If you still face an issue, I'd be happy to help further. :)