WorkerLost错误:辅助进程过早退出:信号11(SIGSEGV)

2024-06-01 09:01:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在这里找到答案,但我没有得到我想要的答案。 所以我把问题贴出来了。

import nltk
from nltk.corpus import stopwords
from sklearn.decomposition import TruncatedSVD
from sklearn.feature_extraction.text import TfidfVectorizer

stopset = set(stopwords.words('english'))
vectorizer = TfidfVectorizer(stop_words=stopset, use_idf=True, ngram_range=[1, 4])
X = vectorizer.fit_transform(document_list)
lsa = TruncatedSVD(n_components=2, n_iter=10)
lsa.fit(X)


results = []
terms = vectorizer.get_feature_names()

出于某种原因,我运行上面的代码。 当我直接用python运行上面的代码时,效果很好,而且我可以得到很好的结果。 但当我在celery中运行上面的代码时(我使用celery和烧瓶),我得到了以下错误。 任何建议对我都有帮助。

enter image description here


Tags: 答案代码fromimportsklearnfeaturefitwords
1条回答
网友
1楼 · 发布于 2024-06-01 09:01:56

我也遇到了同样的问题,我通过将这些库的所有导入放在任务函数中而不是放在文件顶部来解决这个问题。在

@celery.task
def reduce_features(cik):
     from sklearn.decomposition import PCA
     # your code

相关问题 更多 >