简体   繁体   English

如何解决 Jupyter Lab 中的 ModuleNotFoundError?

[英]How can I solve ModuleNotFoundError in Jupyter Lab?

Here is my code about sentiment analysis in python so I had a problem on jupyter lab error is no module name but I had everything about the installing part pip install vaderSentiment and enviroment variable stuff.这是我在 python 中关于情感分析的代码,所以我在 jupyter 实验室遇到了一个问题,错误是没有模块名称,但我有关于安装部分 pip 安装 vaderSentiment 和环境变量的所有内容。 So What should I do?所以我该怎么做?

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'

Try installing its full master branch zip file and unzip it in your main file location then either try importing the same way you did or try this other line of code to import it.尝试安装其完整的主分支 zip 文件并将其解压缩到您的主文件位置,然后尝试以与您相同的方式导入或尝试其他代码行来导入它。

from vaderSentiment import SentimentIntensityAnalyzer

Also check if you have only one version of python installed and not multiple.还要检查您是否只安装了一个版本的 python 而不是多个。

Do try to upgrade pip, python and vaderSentiment to latest versions.请尝试将 pip、python 和 vaderSentiment 升级到最新版本。

pip install --upgrade vaderSentiment

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM