解决:Resource stopwords not found.

解决:Resource stopwords not found.

报错如下

---------------------------------------------------------------------------
LookupError                               Traceback (most recent call last)
E:\Users\TFX\Anaconda3\envs\tensorflow24\lib\site-packages\nltk\corpus\util.py in __load(self)
     82                 try:
---> 83                     root = nltk.data.find("{}/{}".format(self.subdir, zip_name))
     84                 except LookupError:

E:\Users\TFX\Anaconda3\envs\tensorflow24\lib\site-packages\nltk\data.py in find(resource_name, paths)
    582     resource_not_found = "\n%s\n%s\n%s\n" % (sep, msg, sep)
--> 583     raise LookupError(resource_not_found)
    584 

LookupError: 
**********************************************************************
  Resource stopwords not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('stopwords')
  
  For more information see: https://www.nltk.org/data.html

  Attempted to load corpora/stopwords.zip/stopwords/

  Searched in:
    - 'C:\\Users\\TFX/nltk_data'
    - 'E:\\Users\\TFX\\Anaconda3\\envs\\tensorflow24\\nltk_data'
    - 'E:\\Users\\TFX\\Anaconda3\\envs\\tensorflow24\\share\\nltk_data'
    - 'E:\\Users\\TFX\\Anaconda3\\envs\\tensorflow24\\lib\\nltk_data'
    - 'C:\\Users\\TFX\\AppData\\Roaming\\nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
**********************************************************************


During handling of the above exception, another exception occurred:

LookupError                               Traceback (most recent call last)
<ipython-input-3-c87583f8fb10> in <module>
      5 from tensorflow.keras.preprocessing.sequence import pad_sequences
      6 from nltk.corpus import stopwords
----> 7 STOPWORDS = set(stopwords.words('english'))

E:\Users\TFX\Anaconda3\envs\tensorflow24\lib\site-packages\nltk\corpus\util.py in __getattr__(self, attr)
    118             raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
    119 
--> 120         self.__load()
    121         # This looks circular, but its not, since __load() changes our
    122         # __class__ to something new:

E:\Users\TFX\Anaconda3\envs\tensorflow24\lib\site-packages\nltk\corpus\util.py in __load(self)
     83                     root = nltk.data.find("{}/{}".format(self.subdir, zip_name))
     84                 except LookupError:
---> 85                     raise e
     86 
     87         # Load the corpus.

E:\Users\TFX\Anaconda3\envs\tensorflow24\lib\site-packages\nltk\corpus\util.py in __load(self)
     78         else:
     79             try:
---> 80                 root = nltk.data.find("{}/{}".format(self.subdir, self.__name))
     81             except LookupError as e:
     82                 try:

E:\Users\TFX\Anaconda3\envs\tensorflow24\lib\site-packages\nltk\data.py in find(resource_name, paths)
    581     sep = "*" * 70
    582     resource_not_found = "\n%s\n%s\n%s\n" % (sep, msg, sep)
--> 583     raise LookupError(resource_not_found)
    584 
    585 

LookupError: 
**********************************************************************
  Resource stopwords not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('stopwords')
  
  For more information see: https://www.nltk.org/data.html

  Attempted to load corpora/stopwords

  Searched in:
    - 'C:\\Users\\TFX/nltk_data'
    - 'E:\\Users\\TFX\\Anaconda3\\envs\\tensorflow24\\nltk_data'
    - 'E:\\Users\\TFX\\Anaconda3\\envs\\tensorflow24\\share\\nltk_data'
    - 'E:\\Users\\TFX\\Anaconda3\\envs\\tensorflow24\\lib\\nltk_data'
    - 'C:\\Users\\TFX\\AppData\\Roaming\\nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
**********************************************************************

解决方法

python
>>> import nltk
>>> nltk.download('stopwords')

在这里插入图片描述

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FriendshipT

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值