如何解决Jupyter实验室中的ModuleNotFoundError?

2024-06-11 10:47:37 发布

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

这是我在python中关于情绪分析的代码,所以我在jupyter lab上遇到了一个问题,错误是没有模块名,但我有关于安装部分pip install VADERTOMITION和环境变量的所有信息。那我该怎么办

from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyser = SentimentIntensityAnalyzer()

def sentiment_analyzer_scores(sentence):
    score = analyser.polarity_scores(sentence)
    print("{:-<40} {}".format(sentence, str(score)))



 ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-22-f1fda500aee5> in <module>
    ----> 1 from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
          2 analyser = SentimentIntensityAnalyzer()
          3 
          4 def sentiment_analyzer_scores(sentence):
          5     score = analyser.polarity_scores(sentence)
    
    ModuleNotFoundError: No module named 'vaderSentiment'

Tags: fromimportdefanalyzersentencemodulescore情绪
1条回答
网友
1楼 · 发布于 2024-06-11 10:47:37

尝试安装它的full master branch zip file并将其解压缩到主文件位置,然后尝试以与之前相同的方式导入,或者尝试使用另一行代码导入它

from vaderSentiment import SentimentIntensityAnalyzer

还要检查是否只安装了一个python版本,而没有安装多个

请尝试将pip、python和VaderMotion升级到最新版本

pip install  upgrade vaderSentiment

相关问题 更多 >