-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot import pythonjsonlogger.jsonlogger #29
Comments
It juts broke for me as well (using kopf). |
This has broken kopf for us too |
if I see correctly, an attempt was made to stay backward compatible: python-json-logger/src/pythonjsonlogger/__init__.py Lines 22 to 29 in f96de22
but that only seems to work with from pythonjsonlogger import jsonlogger not with import pythonjsonlogger.jsonlogger |
Thanks for digging into that @soxofaan. Short term workaround would be to pin your python-json-logger version. Medium term would be to migrate the underlying code. I will however see if I can fix this bug as I would like to keep backwards compatibility. |
Fixes: #29 Although efforts were made for backwards compatibility using `__getattr__` in `pythonjsonlogger/__init__.py`, this only worked if you were doing `from pythonjsonlogger import jsonlogger`. When importing by the full name `import pythonjsonlogger.jsonlogger` it it would fail to locate the module file and thus not be able to produce a module spec which then of course causes the import to fail. We get around this by actually having a module that imports the names it needs from the new locations.
I've uploaded a development version that should fix this. Would someone be able to test using |
This broke our code as well. quick fix for us was just to add
|
Fixes: #29 Although efforts were made for backwards compatibility using `__getattr__` in `pythonjsonlogger/__init__.py`, this only worked if you were doing `from pythonjsonlogger import jsonlogger`. When importing by the full name `import pythonjsonlogger.jsonlogger` it it would fail to locate the module file and thus not be able to produce a module spec which then of course causes the import to fail. We get around this by actually having a module that imports the names it needs from the new locations. ### Test Plan - Run unit tests
Hi all, I've released a fix for this issue ( I don't currently intend to backport the changes, but could be convinced if someone has a compelling need. |
Thanks, that looks to have solved the issue. |
Was 3.2.0 meant to remove this?
from pythonjsonlogger.jsonlogger import JsonFormatter
Looks to still be deprecated from the release docs, nothing about it being removed (it says moved at the same time as deprecated).
The text was updated successfully, but these errors were encountered: