Upgrade the Flask version from 1.1.2 to 1.1.4 Ĭommands to upgrade the Flask version and downgrade the markupsafe library.However, you will face another issue after upgrading to 1.1.4, which is ImportError: cannot import name ‘soft_unicode’ from ‘markupsafe’, and that can be fixed by downgrading the markupsafe to version 2.0.1 as shown below. The issue can be fixed by upgrading the Flask version to 1.1.4 or above. Solution 2 – Upgrade Flask to 1.1.4 and downgrade the markupsafe to 2.0.1 This will be a major upgrade if you are using the older Flask version like 1.1.2 and may have to test the entire application.Īs an immediate solution If you still want to stick with the same Flask version and resolve this error, then you can go through the below solutions. The best way to resolve this issue is to upgrade the Flask to the latest version, i.e, 2.0.1 or above.
It is also a breaking change in markupsafe and jinja not specifying an upper version bound pallets/markupsafe#286 How to fix ImportError: cannot import name ‘json’ from itsdangerous Solution 1 – Upgrade the Flask to latest version > 2 Checkout the Release Notes for more details. It looks the issue is due to an upgrade in MarkupSafe:2.1.0 where they have removed soft_unicode. This issue seems to be related: ImportError: cannot import name ‘soft_unicode’ from ‘markupsafe’ in Release 1.38.0 #3661 This is used to protect Flask’s session cookie.Įven if you upgrade the Flask version to 1.1.4 you will still get ‘soft_unicode error. ItsDangerous securely signs data to ensure its integrity.It escapes untrusted input when rendering templates to avoid injection attacks. The Flask application has a dependency on the below two packages. The issue is faced mainly when you use the Python application and running the application with Flask version 1.1.2 or Flask version 1.1.4. What is ImportError: cannot import name ‘json’ from itsdangerous? In this article, we will look at what is ImportError: cannot import name ‘json’ from itsdangerous means and how to fix the issue. If you are deploying and running the flask application(1.1.2) using the Docker containers, you will get ImportError: cannot import name ‘json’ from itsdangerous Solution 3 – Downgrade itsdangerous to 2.0.1.Solution 2 – Upgrade Flask to 1.1.4 and downgrade the markupsafe to 2.0.1.Solution 1 – Upgrade the Flask to latest version > 2.How to fix ImportError: cannot import name ‘json’ from itsdangerous.What is ImportError: cannot import name ‘json’ from itsdangerous?.