Python Forum

Full Version: Can't import logging
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
"
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.
You're exactly right sir ! Smile

Thank you so much !