[英]Not able to import from `gensim.summarization` module in Django
[英]How to fix “Relative import error” in python (gensim.summarization)
我正在運行這段代碼
from gensim.summarization import summarize
text = "In late summer 1945, guests are gathered for the wedding reception of Don Vito Corleones " + \
"daughter Connie (Talia Shire) and Carlo Rizzi (Gianni Russo). Vito (Marlon Brando)," + \
"the head of the Corleone Mafia family, is known to friends and associates as Godfather. " + \
"He and Tom Hagen (Robert Duvall), the Corleone family lawyer, are hearing requests for favors " + \
"because, according to Italian tradition, no Sicilian can refuse a request on his daughter's wedding " + \
" day. One of the men who asks the Don for a favor is Amerigo Bonasera, a successful mortician " + \
"and acquaintance of the Don, whose daughter was brutally beaten by two young men because she" + \
"refused their advances; the men received minimal punishment from the presiding judge. " + \
"The Don is disappointed in Bonasera, who'd avoided most contact with the Don due to Corleone's" + \
"nefarious business dealings. The Don's wife is godmother to Bonasera's shamed daughter, " + \
"a relationship the Don uses to extract new loyalty from the undertaker. The Don agrees " + \
"to have his men punish the young men responsible (in a non-lethal manner) in return for " + \
"future service if necessary."
print summarize(text)
第一次運行完全正常。 但是之后,它顯示了以下錯誤,直到我在spyder中重新啟動內核為止:
File "/home/taha/.local/lib/python2.7/site -packages/scipy/sparse/compressed.py", line 50, in __init__ from .coo import coo_matrix
SystemError: Parent module 'scipy.sparse' not loaded, cannot perform relative import
我正在使用ubuntu 18.04
我也發生了 我重新安裝了gensim pypi模塊。
https://www.tutorialspoint.com/python/python_text_summarization.htm
pip install gensim_sum_ext
我相信重新安裝上述模塊會解決它
問題出在spyder IDE。 您可以使用終端(或cmd)運行此代碼而不會出現任何錯誤。 此外,每次在spyder IDE中運行此代碼時,都需要重新啟動內核
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.