NLTK - AttributeError:模块'nltk'没有属性'data'

7 import nltk python-3.x

nltk在我的代码中使用了几天,但现在,当我尝试时import nltk,我收到错误:

File "C:\Users\Nada\Anaconda\lib\site-packages\nltk\corpus\reader\plaintext.py", line 42, in PlaintextCorpusReader 
sent_tokenizer=nltk.data.LazyLoader(

AttributeError: module 'nltk' has no attribute 'data'
Run Code Online (Sandbox Code Playgroud)

weka package昨天安装但是没有用,我不知道这跟那个有什么关系......

我试图更新它,但错误不断出现.

Sam*_*Sam 8

我遇到了同样的问题.我卸载并完全重新安装.它对我有用.

pip uninstall nltk
Run Code Online (Sandbox Code Playgroud)

然后我再次安装它

pip install -U nltk
Run Code Online (Sandbox Code Playgroud)

参考:http://www.nltk.org/install.html


Jag*_*jee 5

我执行了与上面相同的步骤并且它起作用了:

  1. 卸载 - pip uninstall nltk
  2. 安装 - pip install -U nltk
  3. 关闭 Spyder
  4. 重新打开 Spyder。
  5. 要检查 nltk 是否正常工作 - 在 Ipython 控制台中键入:**import nltk**


小智 5

关闭内核并重新启动解决了我的问题。