when I wrote the line
import nltk
in python 2.7 interpreter terminal it is showing SyntaxError:Invalid Syntax
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nani/.local/lib/python2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.collocations import *
File "/home/nani/.local/lib/python2.7/site-packages/nltk/collocations.py", line 35, in <module>
from nltk.probability import FreqDist
File "/home/nani/.local/lib/python2.7/site-packages/nltk/probability.py", line 333
print("%*s" % (width, samples[i]), end=" ") ^
SyntaxError: invalid syntax
How to fix this?
So nltk dropped support to Python2, Try to use older versions of nltk in which it supports python 2 and I found out that nltk 3.0 version supports python 2 [edited - Thanks to user2357112 supports Monica ]
So, Try to download and install previous versions of nltk with the command
pip install nltk==3.0
You can change the version number which is 3.0 int the above mentioned case and can install suitable version whichever you feels working.
It worked for me.If anyone facing same problem can try above mentioned method.
This is not a bug and will not be "fixed" in upcoming versions. NLTK has dropped support for Python 2.