0

I want to use the NLTK-PorterStemmer to find the stems of some words i wrote in a .txt-document, but always get the same Error message. It seems that there is something wrong with the import of the Stemmer. I updated nltk, numpy and matplotlib and using Python 3.5.1 Code begins with:

from nltk.stem.porter import PorterStemmer
from nltk.corpus import Words

and i already get the Error:

Traceback (most recent call last):
  File "detect_wrong_words_stemming.py", line 7, in <module>
    from nltk.stem import *
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\__init__.py", line 114, in <module>
    from nltk.collocations import *
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\collocations.py", line 39, in <module>
    from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\metrics\__init__.py", line 24, in <module>
    from nltk.metrics.segmentation    import windowdiff, ghd, pk
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\nltk\metrics\segmentation.py", line 45, in <module>
    import numpy as np
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\core\__init__.py", line 38, in <module>
    from . import numeric
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\numpy\core\numeric.py", line 37, in <module>
    import pickle
  File "C:\Users\Peter\Desktop\Codes\pickle.py", line 2, in <module>
    import matplotlib.pyplot as pyplot
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\__init__.py", line 124, in <module>
    from . import cbook
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\cbook\__init__.py", line 2595, in <module>
    class _StringFuncParser(object):
  File "C:\Users\Peter\AppData\Local\Programs\Python\Python35\lib\site-packages\matplotlib\cbook\__init__.py", line 2607, in _StringFuncPars
er
    _funcs['quadratic'] = _FuncInfo(np.square,
AttributeError: module 'numpy' has no attribute 'square'

But i dont use matplotlib or numpy in my further code. Why does it import all these things?

tristansokol
  • 4,054
  • 2
  • 17
  • 32

1 Answers1

0

I encountered similar problems. As the comment mentioned, some files with invalid names in the same folder will cause this problem. My case is I have a

threading.py

file in the folder.

lX-Xl
  • 160
  • 1
  • 6