I just installed nltk on a CentOS server. But when I go into python and try to import nltk I get the following error.
Any ideas?
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()}
Since version 3.1, NLTK drops supports for Python < 2.7, from::
Since dictionary comprehension is a feature from Python >=2.7,, using NLTK >=3.1 will lead to error when a dictionary comprehension occurs.
Strongly encouraged to upgrade to Python >= 2.7:
Or using
conda would simplify the problem too:
But if Python 2.6 is really necessary:
pip install -U nltk==3.0.5