简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM