ModuleNotFoundError: No module named 'gensim.models.wrappers' - python

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!

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

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

Related

How to import gensim summarize

I got gensim to work in Google Collab by following this process:
!pip install gensim
from gensim.summarization import summarize
Then I was able to call summarize(some_text)
Now I'm trying to run the same thing in VS code:
I've installed gensim:
pip3 install gensim
but when I run
from gensim.summarization import summarize
I get the error
Import "gensim.summarization" could not be resolvedPylancereportMissingImports
I've also tried from gensim.summarization.summarizer import summarize with same error. Regardless I haven't been able to call the function summarize(some_text) outside of Google Collab.
The summarization code was removed from Gensim 4.0. See:
https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#12-removed-gensimsummarization
12. Removed gensim.summarization
Despite its general-sounding name, the module will not satisfy the
majority of use cases in production and is likely to waste people's
time. See this Github
ticket for
more motivation behind this.
If you need it, you could try:
installing an older gensim version (such as 3.8.3, the last official release in which it remained); or…
copy the source code out to your own local module
However, I expect you'd likely be disappointed by its inflexibility and how little it can do.
It was only extractive summarization - choosing a few key sentences from those that already exist. That only gives impressive results when the source text was already well-written in an expository style mixing high-level overview sentences with separate detail sentences. And, its method of analyzing/ranking words was very crude & hard-to-customize – totally unconnected to the more generic/configurable/swappable approaches used elsewhere in Gensim or in other text libraries.
So I had to download specifically
pip3 install gensim==3.6.0
I was using gensim==4.1.0 and this function no longer seems to work in this later version

Not able to import from `gensim.summarization` module in Django

I have included the 2 import statements in my views.py
from gensim.summarization.summarizer import summarizer
from gensim.summarization import keywords
However, even after I installed gensim using pip, I am getting the error:
ModuleNotFoundError: No module named 'gensim.summarization'
The summarization code was removed from Gensim 4.0. See:
https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#12-removed-gensimsummarization
12. Removed gensim.summarization
Despite its general-sounding name, the module will not satisfy the
majority of use cases in production and is likely to waste people's
time. See this Github
ticket for
more motivation behind this.
If you need it, you could try:
installing the older gensim version; or…
copy the source code out to your own local module
However, I expect you'd likely be disappointed by its inflexibility and how little it can do.
It was only extractive summarization - choosing a few key sentences from those that already exist. That only gives impressive results when the source text was already well-written in an expository style mixing high-level overview sentences with separate detail sentences. And, its method of analyzing/ranking words was very crude & hard-to-customize – totally unconnected to the more generic/configurable/swappable approaches used elsewhere in Gensim or in other text libraries.
You can run pip freeze within your environment to ensure it is installed here.
If it is, then you should check naming of any modules or files you have in your directory to ensure there are no conflicts.
I had the same issue
As per Gensim’s Github changelog 188, gensim.summarization module has been removed in versions Gensim 4.x as it was an unmaintained third-party module.
To continue using gensim.summarization, you will need to downgrade the version of Gensim in the requirements.txt file by replacing it with gensim==3.8.3 or an older version.

How can I access to library " plot_utils " in python?

I need this library "plot_utils" for analysis and plotting but I can't find it in the web. this library is related to Brian2 (a library in python) for spiking neural network.
I installed brian2 through anaconda. when I want to import plot_utils and using in my code I receive error :
ModuleNotFoundError: No module named 'plot_utils'
Could you please help me?
You need to give more info about where did you stumble upon that name, eg some copied code etc.
With the only reference you've given (ie. brian2) this seems related.
https://brian2.readthedocs.io/en/stable/examples/frompapers.Stimberg_et_al_2018.plot_utils.html
Maybe just copy that code into a file named 'plot_utils.py' and keep it at the path your code is searching for it.
First, you need to install the module in your work environment using "pip install plot_utils" then you can import the library using "import plot_utils".
This link will help you: https://libraries.io/pypi/plot-utils[this is the official documentation from plot_utils]

Issue downloading Python Panda's module

I am a programming novice, so apologize in advance if I'm asking a dumb question or perpetrating some site etiquette violation. I have tried very hard to research the answer to my question on an issue that seems to be very common, but none of the proposed solutions have worked, so am looking for some help as I just don't know what to try next.
I'm trying to import Panda from iPython onto Windows 8. I have version 2.7 of Python and have successfully downloaded Numpy. Given the suggestions on this site, I have downloaded all the file that I think Panda is dependent on (pytx, dateutil, setuptools), but it still didn't work: the error message includes:
Import Error Traceback (most recent call)
<ipython-input-2-d6ac987968b6> in <module>()
try
from.import hashtable, tslib, lib
except exception: # pragma: no cover
import datetime
- C: \Python27\lib\site-packages\pandas\__init__.py in <module>():
Import Error: No module named six
Out of desperation, I also deleted all previous version of pandas and loaded Aneconda, thinking from previous responses that might help capture all required modules including Pandas, but the same error keeps coming up.
Any help would be much appreciated, and don't worry about pointing out the obvious (since it's clearly not obvious to me.)
The easiest way to get modules up and running on Windows is to use Christoph Gohlke's Python Extension Packages for Windows repository. It includes installers for a ton of (mainly scientific-related) modules, including pandas, matplotlib, six, etc. Since many modules included compiled extensions, installing using pip doesn't always work if the package maintainer hasn't published a binary for your package of interest. Gohlke's packages include everything already pre-compiled, you just need to choose the version and bit-ness of Python, and download the .exe files.

unable to use TfidfVectorizer in Google app engine

I am writing a python program in Google App Engine that calculates tf-idf using TfidfVectorizer in sklearn.
I have added sklearn library and have the import as:
from sklearn.feature_extraction.text import TfidfVectorizer
However it gives me no module named _check_build although it is in the library that I have imported.
Note: I have the same code in pure python and it works just fine so there is nothing wrong with the python syntax or imports; The problem starts with GAE.
Do you know any way to solve this issue?
You can't. sklearn has a lot of 'c' based dependencies and typically any module that is named with a leading _ is a binary module.
So that's why you are getting a no module named _check_build error.
I seriously doubt you will get it to run even if you fake some of the 'c' libs unless they have pure python analogues.
I have done this in the past where libs had 'c' based performance versions as well as pure python.
if you are not using any of GAE-specific tools, try deploying your app on Heroku.
It let's you deploy a whole virtual environment with all the installed libraries on it. Specifically, Scikit-learn works on Heroku just fine. Check this Github repo for example.

Categories