Skip to content
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

json package error on fresh install #363

Closed
davewj100 opened this issue Feb 18, 2022 · 4 comments · Fixed by #364
Closed

json package error on fresh install #363

davewj100 opened this issue Feb 18, 2022 · 4 comments · Fixed by #364

Comments

@davewj100
Copy link

Summary

Found this issue at runtime: ImportError: cannot import name 'json' from 'itsdangerous' on Ubuntu 20.04 LTS Server
... and found a workaround to fix it

Full Error Message

(lxdui) sa@hive:~/lxdui$ python3 run.py
Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from app.cli.cli import lxdui
  File "/home/sa/lxdui/app/cli/cli.py", line 6, in <module>
    from app.api import core
  File "/home/sa/lxdui/app/api/core.py", line 3, in <module>
    from flask import Flask, redirect
  File "/home/sa/lxdui/lib/python3.8/site-packages/Flask-1.0.2-py3.8.egg/flask/__init__.py", line 21, in <module>
    from .app import Flask, Request, Response
  File "/home/sa/lxdui/lib/python3.8/site-packages/Flask-1.0.2-py3.8.egg/flask/app.py", line 25, in <module>
    from . import cli, json
  File "/home/sa/lxdui/lib/python3.8/site-packages/Flask-1.0.2-py3.8.egg/flask/json/__init__.py", line 21, in <module>
    from itsdangerous import json as _json
ImportError: cannot import name 'json' from 'itsdangerous' (/home/sa/lxdui/lib/python3.8/site-packages/itsdangerous-2.1.0-py3.8.egg/itsdangerous/__init__.py)

Workaround

Noticed this message on this page: itsdangerous Changelog
"Importing itsdangerous.json is deprecated. Import Python’s json module instead."

Modified: /home/sa/lxdui/lib/python3.8/site-packages/Flask-1.0.2-py3.8.egg/flask/json/init.py

# Use the same json implementation as itsdangerous on which we
# depend anyways.
# mod by DJ
# from itsdangerous import json as _json
import json as _json

It's a bit of a hack but it seems to work. Happens on fresh install with Ubuntu 20.04 LTS Server.

Dave

@OllieSteam
Copy link

OllieSteam commented Apr 6, 2022

Yea got the same error,
ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.9/dist-packages/itsdangerous-2.1.2-py3.9.egg/itsdangerous/__init__.py)

Ubuntu Server 21.10 "Impish Indri" (64bits)

@emwadde
Copy link

emwadde commented Jun 5, 2022

I was able to fix it by manually installing itsdangerous==2.0.1 and Werkzeug==2.0.0
Try running the pip commands below
pip3 install itsdangerous==2.0.1
pip3 install Werkzeug==2.0.0

@ghost
Copy link

ghost commented Mar 9, 2023

Same issue ubuntu server 21.10

@emwadde
Copy link

emwadde commented Mar 10, 2023

Since this repo hasn't been updated recently and some dependencies has been updated with non-backwards compatible changes, I suggest to use the lxd-ui by Canonical
It appears to be the official UI for lxd.

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

Successfully merging a pull request may close this issue.

3 participants