2

I need to run a model but it needs older version of gensim with DocvecsArray attribute.How can i run it?

AttributeError: Can't get attribute 'DocvecsArray' on <module 'gensim.models.doc2vec'...

1 Answers1

1

The DocvecsArray class was removed by Gensim-3.3.0, released in February 2018. So your model, or the code-installation that created it, used a version of Gensim more than 3 years old.

However, it's possible your model will still load in Gensim-3.8.3 – I'm not sure, you'd have to try it.

You can always choose to install an older version of Gensim, or any other library, instead of the latest, when setting up your environment from public package repositories.

If you've been installing Gensim using pip at your command-line in your working environment, you could try uninstalling the current Gensim & then installing a specific exact earlier version:

pip uninstall gensim

pip install gensim==3.8.3

But, some caveats:

  • you might need to roll-back to gensim==3.2.0
  • because of all the other potential libraries involved, which might also need to be rolled-back to compatible versions, it may make sense to start a fresh virtual environment, building it up with each requirement (starting with the most-important ones or the ones with the strongest version limitations)
  • if using some other Python distribution or environment-manager (like conda), the installation commands will change a bit

Also note, the later versions of Gensim have many bug fixes & performance improvements, so if at all possible you should try to either migrate your model forward to be used with the latest library, or re-train a fresh model for the same purposes with either the original or updated data.

Once you manage to load it into a working version, you can re-save it, and another version close should be able to re-load it. For example, if 3.8.3 manages to load your model, then you re-saved it, then current 4.x Gensim should be able to load that save.

gojomo
  • 52,260
  • 14
  • 86
  • 115