为了账号安全,请及时绑定邮箱和手机立即绑定

在 MACOS 上安装 NLTK

在 MACOS 上安装 NLTK

子衿沉夜 2021-11-23 17:58:56
我正在尝试使用 Mac OS Mojave 在我的 2015 Mac Pro 上安装 NLTK。我用了sudo pip install nltk它下载了安装文件并成功安装。当我进入 python 并输入时nltk.download()我明白了NLTK Downloader---------------------------------------------------------------------------d) Download   l) List    u) Update   c) Config   h) Help   q) Quit---------------------------------------------------------------------------Downloader>使用“d”后,它下载了一些包和模块。但是,当我尝试运行它时,我无法使用 nltkfrom nltk.tokenize import sent_tokenize, word_tokenizedata = "All work and no play makes jack dull boy. All work and no play makes jack a dull boy."print(sent_tokenize(data))这给了我一个错误说:File "token.py", line 1, in <module>from nltk.tokenize import sent_tokenize, word_tokenizeFile "/Library/Python/2.7/site-packages/nltk/__init__.py", line 129, in <module>from nltk.collocations import *File "/Library/Python/2.7/site-packages/nltk/collocations.py", line 38, in <module>from nltk.util import ngramsFile "/Library/Python/2.7/site-packages/nltk/util.py", line 10, in <module>import inspectFile "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 39, in <module>import tokenizeFile "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tokenize.py", line 31, in <module>from token import *File "/Users/Documents/NLTK/token.py", line 1, in <module>from nltk.tokenize import sent_tokenize, word_tokenizeFile "/Library/Python/2.7/site-packages/nltk/tokenize/__init__.py", line 67, in <module>from nltk.tokenize.mwe import MWETokenizerFile "/Library/Python/2.7/site-packages/nltk/tokenize/mwe.py", line 31, in <module>from nltk.util import TrieImportError: cannot import name Trie请帮忙!
查看完整描述

1 回答

?
繁星淼淼

TA贡献1775条经验 获得超11个赞

转到python控制台并输入

nltk.download('all')


查看完整回答
反对 回复 2021-11-23
  • 1 回答
  • 0 关注
  • 262 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信