Python 导入nltk无法理解的错误
我刚刚在CentOS服务器上安装了nltk。但是当我进入python并尝试导入nltk时,我得到了以下错误 有什么想法吗Python 导入nltk无法理解的错误,python,centos,nltk,python-2.6,dictionary-comprehension,Python,Centos,Nltk,Python 2.6,Dictionary Comprehension,我刚刚在CentOS服务器上安装了nltk。但是当我进入python并尝试导入nltk时,我得到了以下错误 有什么想法吗 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/site-packages/nltk/__init__.py", line 114, in <module> from nltk.co
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/nltk/__init__.py", line 114, in <module>
from nltk.collocations import *
File "/usr/lib/python2.6/site-packages/nltk/collocations.py", line 38, in <module>
from nltk.util import ngrams
File "/usr/lib/python2.6/site-packages/nltk/util.py", line 1361
d = {k: _default_to_regular(v) for k, v in d.items()}
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/usr/lib/python2.6/site packages/nltk/_init__.py”,第114行,在
从nltk.consolutions导入*
文件“/usr/lib/python2.6/site packages/nltk/collabons.py”,第38行,在
从nltk.util导入ngrams
文件“/usr/lib/python2.6/site packages/nltk/util.py”,第1361行
d={k:_default_到_regular(v)表示k,v在d.items()中
自3.1版以来,NLTK从以下位置删除了对Python<2.7的支持:
NLTK 3.1发布日期:2015年10月
添加对Python 3.5的支持,删除
支持Python2.6、情绪分析包和一些
语料库、改进的POS标记器、Twitter软件包、多词表达
标记器,斯坦福神经依赖解析器的包装器,改进
翻译/对齐模块,包括堆栈解码器、skipgram和
everygram方法,多文本东部语料库和MTECorpusReader,小调
有关错误修复和增强的详细信息,请参阅:
由于字典理解是Python>=2.7中的一项功能,因此当字典理解发生时,使用NLTK>=3.1将导致错误
强烈建议升级到Python>=2.7:
或者使用conda
也可以简化问题:
但是,如果Python 2.6确实是必要的:
pip install -U nltk==3.0.5
NLTK不再支持python 2.6。您必须降级NLTK或升级python=)我现在面临的相同错误。谢谢您的帮助。在您回答之前找到github链接,当您实际评论时:)它不应该是
nltk==3.0.5
?谢谢,一个错误=)