PyCharm NLTK Problem?

1,649 views
Skip to first unread message

Masoud Komeily

unread,
Feb 13, 2014, 4:53:18 PM2/13/14
to nltk-...@googlegroups.com
Hi,

 With MAC OS X 10.8.5, my Python code worked well for calculating N-grams of Persian *.txt files using NLTK on Python IDLE 2.7.5, but the same code does not work on PyCharm Community Edition 3.1, and gives out below error:

Traceback (most recent call last):
  File "/Users/Masoud/Documents/-- NLP --/3-NLP Python Prolog/Python Code/N-Gram NM/N-Gram NM 2.7.2.py", line 1, in <module>
    import nltk
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/nltk/__init__.py", line 37
    except IOError, ex:
                  ^
SyntaxError: invalid syntax


I have also followed all instructions on http://www.nltk.org/install.html through terminal window on PyCharm and have re-downloaded all required NLTK material. The problem, however, still stays. Can any one you help?


Thanks,
Masoud

Mikhail Korobov

unread,
Feb 14, 2014, 2:43:55 AM2/14/14
to nltk-...@googlegroups.com
Hi Masoud,

It looks like your PyCharm is configured to use Python 3.3, and that you've installed NLTK from PyPI. The problem is that NLTK from PyPI (2.0.4) doesn't support Python 3.x. You may either configure PyCharm to use Python 2.x or install NLTK from github (https://github.com/nltk/nltk) or NLTK3 aplhs (http://www.nltk.org/nltk3-alpha/) - these NLTK versions support Python 3.x, but have some backwards incompatible changes (see https://github.com/nltk/nltk/wiki/Porting-your-code-to-NLTK-3.0). 

пятница, 14 февраля 2014 г., 3:53:18 UTC+6 пользователь Masoud Komeily написал:

Masoud Komeily

unread,
Feb 14, 2014, 12:35:45 PM2/14/14
to nltk-...@googlegroups.com
Hi,

Thank you Mikhail. I deleted/uninstalled all IDLE versions and reinstalled 2.7.5 version only which now works perfect within PyCharm Community Edition 3.1 as well.

- Masoud Komeily  




--
You received this message because you are subscribed to a topic in the Google Groups "nltk-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nltk-users/HKT14DP5lR0/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to nltk-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages