install - ImportError: cannot import name porter python -


i importing nltk library in project , giving following error. if has same error, please help.

        traceback (most recent call last):   file "/home/nitai/dropbox/thesis/pycharmprojects/auto_tagger2/tagger.py", line 4, in <module>     import buildvocab   file "/home/nitai/dropbox/thesis/pycharmprojects/auto_tagger2/buildvocab.py", line 4, in <module>     import nltk   file "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 126, in <module>     nltk.stem import *   file "/usr/local/lib/python2.7/dist-packages/nltk/stem/__init__.py", line 29, in <module>     nltk.stem.snowball import snowballstemmer   file "/usr/local/lib/python2.7/dist-packages/nltk/stem/snowball.py", line 25, in <module>     nltk.stem import porter importerror: cannot import name porter 

i have installed nltk packages. don't know.

if have downloaded data packages nltk, i.e.

>>> import nltk >>> nltk.download('all') 

porter stemmer in nltk class not package/module.

you should import porterstemmer class instead:

>>> nltk.stem import porterstemmer >>> porter = porterstemmer() >>> porter.stem('went') u'went' >>> porter.stem('running') u'run' 

also, check have latest stable version of nltk installing pip. otherwise, might using unstable/outdated version of nltk. see http://www.nltk.org/install.html


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -