Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't import logging
#1
Hi

I'm on a Raspberry pi and VSCode trying to import 'logging' but I get an error despite it should already be with python 3.9.2.

When I import 'math' from a terminal in VSCode, it works ok. But importing logging doesn't.

Trying to import 'logging' from a terminal outside VSCode works !

Something strange is that the error refers to part of my code in VSCode
"from logging.handlers import RotatingFileHandler
ModuleNotFoundError: No module named 'logging.handlers'; 'logging' is not a package
"
Reply
#2
The error message makes me think you have a file named "logging.py" that hides the logging package. For some reason when you run from the command line Python does not see this file.
hary likes this post
Reply
#3
You're exactly right sir ! Smile

Thank you so much !
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  import logging not working segerhult 3 13,258 Feb-07-2019, 05:31 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020