Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named 'logging.handlers'; 'logging' is not a package

Tags:

python-3.x

I will use RotatingFileHandler in Python 3.5.3 64 bit

I try a lot of example, but by all I got the same Error after few lines:

import logging
from logging.handlers import RotatingFileHandler

but I got the folling Error:

ImportError: No module named 'logging.handlers'; 'logging' is not a package
like image 331
SvenH Avatar asked Jan 25 '17 08:01

SvenH


1 Answers

Sorry, I was not able to read the Errormessage in the right way. My mistake was the filename logging.py - the Py-file was opened by himself

Traceback (most recent call last):
  File "C:\Python-Projects\logging.py", line 1, in <module>
    import logging
  File "C:\Python-Projects\logging.py", line 2, in <module>
    from logging.handlers import RotatingFileHandler
ImportError: No module named 'logging.handlers'; 'logging' is not a package

Solution is rename the file to anything else like logging-test.py and be sure, that there is no other file like logging.py.

I spent 3 days for that mistake. Thanks for support.

like image 96
SvenH Avatar answered Sep 23 '22 19:09

SvenH