下面是我用来将wordcloud导入到烧瓶应用程序的代码,但它显示错误"信号仅适用于主线程"而且我也无法导入名称WordCloud。
@app.route('/Wordcloud')
def Wordcloud():
user_input = "pogba"
vats = []
tweets = api.search(user_input)
for tweet in tweets:
# print(tweet.text)
vats.append(tweet.text)
analysis = TextBlob(tweet.text)
# print(analysis.sentiment)
# print()
vat = ' '.join(vats)
words = re.split( r'(https:)\S+', vat)
for word in words:
if word == "https:":
words.remove(word)
vat1 = ' '.join(words)
words2 = re.split( r'(@)\S+', vat1)
for word in words2:
if word == "@":
words2.remove(word)
vat2 = ' '.join(words2)
words3 = re.split( r'\s(RT)\s', vat2)
for word in words3:
if word == "RT":
words3.remove(word)
vat3 = ' '.join(words3)
#%matplotlib inline
plt.figure(figsize=(20,10))
wordcloud = WordCloud(background_color='white', mode = "RGB", width = 2000, height = 1000).generate(vat3)
plt.title("text wordcloud")
plt.imshow(wordcloud)
plt.axis("off")
return(plt.show())
答案 0 :(得分:0)
您的函数名称与您尝试导入的另一个类的名称相同。
将def Wordcloud()
更改为def Wordcloud_something()