首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复python (gensim.summarization)中的“相对导入错误”

如何修复python (gensim.summarization)中的“相对导入错误”
EN

Stack Overflow用户
提问于 2018-12-31 15:52:48
回答 2查看 128关注 0票数 0

我在运行这段代码

代码语言:javascript
复制
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中的内核:

代码语言:javascript
复制
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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-06-25 10:53:49

问题在于spyder。您可以使用终端(或cmd)运行此代码,而不会出现任何错误。此外,每次在spyder中运行此代码时,都需要重新启动内核

票数 0
EN

Stack Overflow用户

发布于 2019-02-15 16:59:44

也发生在我身上。我重新安装了gensim pypi模块。

summarization.htm

代码语言:javascript
复制
 pip install gensim_sum_ext 

我相信重新安装上面的模块会修复它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53989210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档