1

Whenever I execute the following script: https://bitbucket.org/pedro_stanaka/flock-log-parser/src/1340cdb7f873f158d3778aec445e4e37ee5f2a32/main.py?fileviewer=file-view-default

Inside its original folder (as it is in the project) i get the following error:

Traceback (most recent call last):
   File "main.py", line 7, in <module>
   from matplotlib.backends.backend_pdf import PdfPages
[...] 
File "/usr/lib/python3.4/unittest/case.py", line 253, in <module>
class _CapturingHandler(logging.Handler):
AttributeError: 'module' object has no attribute 'Handler'

But when I copied the script (and JUST the script) to another folder in my computer and ran it using the same command line it worked.

    python3.4 main.py

Why is this happening? Is there any explanation at all for this behavior? I would like very much to keep the same folder/project.

I've tried to set PYTHONPATH and it did not work as well.

4
  • Do you have a file called logging.py sitting in the same directory? Commented Mar 4, 2016 at 4:46
  • 1
    OH MY GOD! Bad days I'm getting through! It was that. I never saw that folder there! Thank you. Make this Comment an answer and I'll accept. Commented Mar 4, 2016 at 4:48
  • I actually have a set of tools I can't use in two separate directories because the Python string library has a "codecs" module and so do these folders... Commented Mar 4, 2016 at 4:56
  • In my case I just renamed it. Easiest path since I'm using PyCharm here. Commented Mar 4, 2016 at 5:01

1 Answer 1

1
class _CapturingHandler(logging.Handler):
AttributeError: 'module' object has no attribute 'Handler'

Python's logging module will always have this attribute Handler, so I can guess that you have another file called logging.py hanging around in the same directory. Rename that module to some other name not conflicting with the core module.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.