Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error: cannot import name 'BaseKeyedVectors' from 'gensim.models.keyedvectors' #7

Closed
santoshbs opened this issue Dec 19, 2020 · 2 comments

Comments

@santoshbs
Copy link

Thanks for making this very useful python package.

I tried to use it. But get an error with the following line:
from wefe.query import Query


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-02319299b065> in <module>
----> 1 from wefe.query import Query
      2 from wefe.word_embedding_model import WordEmbeddingModel
      3 from wefe.metrics.WEAT import WEAT
      4 #import gensim.downloader as api

/anaconda/envs/py37_default/lib/python3.7/site-packages/wefe/__init__.py in <module>
----> 1 from .word_embedding_model import WordEmbeddingModel
      2 from .query import Query
      3 from .metrics.base_metric import BaseMetric
      4 from .metrics.WEAT import WEAT
      5 from .metrics.RND import RND

/anaconda/envs/py37_default/lib/python3.7/site-packages/wefe/word_embedding_model.py in <module>
----> 1 from gensim.models.keyedvectors import BaseKeyedVectors
      2 
      3 
      4 class WordEmbeddingModel:
      5     """A container for Word Embedding pre-trained models.

ImportError: cannot import name 'BaseKeyedVectors' from 'gensim.models.keyedvectors' (/anaconda/envs/py37_default/lib/python3.7/site-packages/gensim/models/keyedvectors.py)


@santoshbs santoshbs changed the title Imprt error: cannot import name 'BaseKeyedVectors' from 'gensim.models.keyedvectors' Import error: cannot import name 'BaseKeyedVectors' from 'gensim.models.keyedvectors' Dec 19, 2020
@pbadillatorrealba
Copy link
Member

Hello @santoshbs ,

The error you are describing is related to the gensim package.
Maybe it's not installed or if it is installed, you have an older version.

If you use pip as a python package manager, try running it on a console:

pip install --upgrade gensim

If you use anaconda, try running:

conda install -c conda-forge gensim

Tell me if it doesn't work.

Best regards,
Pablo.

@santoshbs
Copy link
Author

Thanks a lot, @pabloBad. It worked with the following steps:
Downgrade Python to 3.8.0 or 3.7.0.
Downgrade gensim from 4.0 to 3.8.3.

Unfortunately, I had created a word2vec model using Gensim 4.0. An environment with gensim 3.8.3 does not seem to load this. So I guess I have to retrain the model with 3.8.3 and try WEAT for bias.

This was referenced Dec 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants