Skip to content

Error cannot import name 'json' from 'itsdangerous' #14

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

Closed
frossi-git opened this issue Mar 11, 2022 · 3 comments
Closed

Error cannot import name 'json' from 'itsdangerous' #14

frossi-git opened this issue Mar 11, 2022 · 3 comments

Comments

@frossi-git
Copy link

A fresh test installation of iris logs the following error, after creating a VM instance that should be tagged:

ImportError: cannot import name 'json' from 'itsdangerous' (/layers/google.python.pip/pip/lib/python3.8/site-packages/itsdangerous/__init__.py)

at .<module> ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/json/__init__.py:15](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fflask%2Fjson%2F__init__.py&line=15&project=iris-test-xxxxxx) )
at .<module> ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/__init__.py:19](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fflask%2F__init__.py&line=19&project=iris-test-xxxxxx) )
at .<module> ( [/srv/main.py:11](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Fsrv%2Fmain.py&line=11&project=iris-test-xxxxxx) )
at ._call_with_frames_removed ( [<frozen importlib._bootstrap>:219](https://console.cloud.google.com/debug?referrer=fromlog&file=%3Cfrozen%20importlib._bootstrap%3E&line=219&project=iris-test-xxxxxx) )
at .exec_module ( [<frozen importlib._bootstrap_external>:843](https://console.cloud.google.com/debug?referrer=fromlog&file=%3Cfrozen%20importlib._bootstrap_external%3E&line=843&project=iris-test-xxxxxx) )
at ._load_unlocked ( [<frozen importlib._bootstrap>:671](https://console.cloud.google.com/debug?referrer=fromlog&file=%3Cfrozen%20importlib._bootstrap%3E&line=671&project=iris-test-xxxxxx) )
at ._find_and_load_unlocked ( [<frozen importlib._bootstrap>:975](https://console.cloud.google.com/debug?referrer=fromlog&file=%3Cfrozen%20importlib._bootstrap%3E&line=975&project=iris-test-xxxxxx) )
at ._find_and_load ( [<frozen importlib._bootstrap>:991](https://console.cloud.google.com/debug?referrer=fromlog&file=%3Cfrozen%20importlib._bootstrap%3E&line=991&project=iris-test-xxxxxx) )
at ._gcd_import ( [<frozen importlib._bootstrap>:1014](https://console.cloud.google.com/debug?referrer=fromlog&file=%3Cfrozen%20importlib._bootstrap%3E&line=1014&project=iris-test-xxxxxx) )
at .import_module ( [/opt/python3.8/lib/python3.8/importlib/__init__.py:127](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Fopt%2Fpython3.8%2Flib%2Fpython3.8%2Fimportlib%2F__init__.py&line=127&project=iris-test-xxxxxx) )
at .import_app ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/util.py:359](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Futil.py&line=359&project=iris-test-xxxxxx) )
at .load_wsgiapp ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py:48](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Fapp%2Fwsgiapp.py&line=48&project=iris-test-xxxxxx) )
at .load ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py:58](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Fapp%2Fwsgiapp.py&line=58&project=iris-test-xxxxxx) )
at .wsgi ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/app/base.py:67](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Fapp%2Fbase.py&line=67&project=iris-test-xxxxxx) )
at .load_wsgi ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/workers/base.py:146](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Fworkers%2Fbase.py&line=146&project=iris-test-xxxxxx) )
at .init_process ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/workers/base.py:134](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Fworkers%2Fbase.py&line=134&project=iris-test-xxxxxx) )
at .init_process ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/workers/gthread.py:92](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Fworkers%2Fgthread.py&line=92&project=iris-test-xxxxxx) )
at .spawn_worker ( [/layers/google.python.pip/pip/lib/python3.8/site-packages/gunicorn/arbiter.py:589](https://console.cloud.google.com/debug?referrer=fromlog&file=%2Flayers%2Fgoogle.python.pip%2Fpip%2Flib%2Fpython3.8%2Fsite-packages%2Fgunicorn%2Farbiter.py&line=589&project=iris-test-xxxxxx) )

Googling for the problem I found similar answers:
https://itsmycode.com/importerror-cannot-import-name-json-from-itsdangerous
https://stackoverflow.com/questions/71189819/python-docker-importerror-cannot-import-name-json-from-itsdangerous

I tried updating requirements.txt with:

Flask==1.1.4
markupsafe==2.0.1

but I had versions conflicts:

ERROR: Cannot install -r requirements.txt (line 1) and -r requirements.txt (line 9) because these package versions have conflicting dependencies.

The conflict is caused by:
    flask 1.1.4 depends on click<8.0 and >=5.1
    black 22.1.0 depends on click>=8.0.0

Then I tried updating to the latest Flask version:

Flask==2.0.3

This last attempt was successful, the application is deployed correctly and no more errors are logged.
VM instances are tagged correctly, but i haven't tested other services.

@JoshuaFox
Copy link
Contributor

Thank you, Filippo! I'll work on that early next week. If you'd like to submit a PR, that would be great.

(This dependency change has been hitting a lot of projects recently, but the version update should do it.)

@frossi-git
Copy link
Author

There you go! Thanks.

@JoshuaFox
Copy link
Contributor

Fixed with merge as mentioned above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants