madzak/python-json-logger

ImportError: cannot import name 'jsonlogger' from partially initialized module 'pythonjsonlogger' (most likely due to a circular import)

renatompf opened this issue · 3 comments

When I try to run this example:

import logging
from pythonjsonlogger import jsonlogger

logger = logging.getLogger()

logHandler = logging.StreamHandler()
formatter = jsonlogger.JsonFormatter()
logHandler.setFormatter(formatter)
logger.addHandler(logHandler)

Error:

ImportError: cannot import name 'jsonlogger' from partially initialized module 'pythonjsonlogger' (most likely due to a circular import)

This error appears to me. Anyone knows why? I'm running it on a MacBook Pro M1 with MacOS Monterrey 12.6.

Hey @renatompf 👋

Did you manage to fix that?

If not, can you give us all the steps you made to have this issue so that we can reproduce the issue? Thank you

Please re open if this is still an issue.

Hi, just ran into this issue, and the cause was quite silly - the file in which I placed this code was named logging.py 🤦🏼‍♂️