I am trying to use LDA MAllet model. but I am facing with "No module named 'gensim.models.wrappers'" error.

  • I have gensim installed and ' gensim.models.LdaMulticore' works properly.

  • Java developer’s kit is installed

  • I have already downloaded mallet-2.0.8.zip and unzipped it on c:\ drive.

  • This is the code I am trying to use:

    import os from gensim.models.wrappers import LdaMallet os.environ.update({'MALLET_HOME':r'C:/mallet-2.0.8/'}) mallet_path = r'C:/mallet-2.0.8/bin/mallet' 

Does anyone know what is wrong here? Many thanks!

2 Answers

If you've installed the latest Gensim, 4.0.0 (as of late March, 2021), the LdaMallet model has been removed, along with a number of other tools which simply wrapped external tools/APIs.

You can see the note in the Gensim migration guide at:

If the use of that tool is essential to your project, you may be able to:

  • install an older version of Gensim, such as 3.8.3 - though of course you'd then be missing the latest fixes & optimizations on any other Gensim models you're using

  • extract the ldamallet.py source code from that older version & update/move it to your own code for private use - dealing with whatever issues arise

I had the same issue with Gensim's wrapper for MALLET but didn't want to downgrade. There is this new wrapper that seems to do the job pretty well.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy