ModuleNotFoundError: No module named 'gensim.models.wrappers'
Asked Answered
M

2

6

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!

Magalymagan answered 31/3, 2021 at 8:41 Comment(0)
A
5

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:

https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#15-removed-third-party-wrappers

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

Accordance answered 31/3, 2021 at 15:45 Comment(0)
A
4

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.

https://github.com/maria-antoniak/little-mallet-wrapper/blob/master/demo.ipynb

Areopagite answered 19/4, 2021 at 3:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.