Python/Docker ImportError: cannot import name ‘json’ from itsdangerous

We Are Going To Discuss About Python/Docker ImportError: cannot import name ‘json’ from itsdangerous. So lets Start this Python Article.

Python/Docker ImportError: cannot import name ‘json’ from itsdangerous

Advertisements
  1. How to solve Python/Docker ImportError: cannot import name 'json' from itsdangerous

    The import failure seems to be related with the latest release version of the package itsdangerous.
    Check the latest releases here
    In my case, I made it work by explicitly adding the package dependency itsdangerous==2.0.1 in my requirements.txt file.
    To make changes effective, update your virtual environment to reflect the new requirements.txt.

  2. Python/Docker ImportError: cannot import name 'json' from itsdangerous

    The import failure seems to be related with the latest release version of the package itsdangerous.
    Check the latest releases here
    In my case, I made it work by explicitly adding the package dependency itsdangerous==2.0.1 in my requirements.txt file.
    To make changes effective, update your virtual environment to reflect the new requirements.txt.

Solution 1

Advertisements

The import failure seems to be related with the latest release version of the package itsdangerous.
Check the latest releases here

In my case, I made it work by explicitly adding the package dependency itsdangerous==2.0.1 in my requirements.txt file.

To make changes effective, update your virtual environment to reflect the new requirements.txt.

Original Author JoeBigToe Of This Content

Solution 2

Advertisements

I just put itsdangerous==2.0.1 in my requirements.txt .Then updated my virtualenv using pip install -r requirements.txt and then docker-compose up --build . Now everything fine for me. Didnot upgrade the flask version.

Original Author Safayet Jamil Of This Content

Solution 3

Advertisements

Solution 1 – Upgrade the Flask to latest version i.e, 2.0.1 or above. It’s the recommended way to fix the issue.

pip install Flask=2.0.1

OR

pip install Flask=2.1.0

Solution 2 – Since it difficult to upgrade to latest version of Flask in shorter time, you can try below methods to resolve the issue.

you can continue using the Flask version 1.1.2 and try downgrading the itdangerous to 2.0.1. You can do this by adding itsdangerous==2.0.1 to your requirements.txt file.

Solution 3 – Another way is to upgrade Flask from 1.1.2 to 1.1.4 as it does not have ground breaking changes and also downgrade the markupsafe library to 2.0.1

Once you upgrade from Flask 1.1.2 to 1.1.4 you will face another issue after, which is ImportError: cannot import name ‘soft_unicode’ from ‘markupsafe’ in Release 1.38.0 #3661, and that can be fixed by downgrading the markupsafe to version 2.0.1 as shown below.

pip install Flask==1.1.4
pip install markupsafe==2.0.1

Reference – [Solved] ImportError: cannot import name ‘json’ from itsdangerous

Original Author Srinivas Ramakrishna Of This Content

Solution 4

Advertisements

Adding itsdangerous==2.0.1 to my requirements.txt file, and downgrading to Flask==1.1.1 fixed it for me.

Original Author joe hoeller Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment