4

I have a very wierd problem. When i run the file from a different directory it runs fine. but other wise i get this error

 from textprocessor import *
File "/home/mohit/Documents/analysis/categorization/textprocessor.py", line 2, in <module>
  import nltk
File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 101, in <module>
 import ccg
File "/usr/local/lib/python2.7/dist-packages/nltk/ccg/__init__.py", line 15, in <module>
   from chart import *
File "/usr/local/lib/python2.7/dist-packages/nltk/ccg/chart.py", line 33, in <module>
from nltk.parse.api import *
File "/usr/local/lib/python2.7/dist-packages/nltk/parse/__init__.py", line 46, in <module>
from featurechart import *
 File "/usr/local/lib/python2.7/dist-packages/nltk/parse/featurechart.py", line 24, in <module>
import nltk.data
 File "/usr/local/lib/python2.7/dist-packages/nltk/data.py", line 41, in <module>
import zipfile
File "/usr/lib/python2.7/zipfile.py", line 460, in <module>
class ZipExtFile(io.BufferedIOBase):
AttributeError: 'module' object has no attribute 'BufferedIOBase'

I am tryin to import nltk module

3 Answers 3

9

You've called a script in the same directory "io.py", and this is interfering with the io module in the stdlib. Rename it.

Sign up to request clarification or add additional context in comments.

1 Comment

Might also need to adjust python path as io.py seems popular across a few pypi available packages.
2

You must have a script in your folder named nltk.py, io.py, zipfile.py, or some such. When you run the file in the same directory, it is imported instead of the appropriate python or nltk module.

Comments

0

Where is nltk? Is it pure Python code? You may want to put that in site-wide modules folder or in your cwd.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.