ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.8/site-packages/markupsafe/__init__.py)
nitsharm1910 opened this issue ยท 11 comments
With the new release getting the below error. It is working fine with version= 2.0.1
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.8/site-packages/markupsafe/init.py)
Yes, that is correct. The function was removed in the minor release three hours ago... It is in the patchnotes -.-
From the changelog https://markupsafe.palletsprojects.com/en/2.1.x/changes/#version-2-1-0
Remove soft_unicode, which was previously deprecated. Use soft_str instead. [#261](https://github.com/pallets/markupsafe/pull/261)
But why doing a breaking change in a minor version?!
I am using python:3.7 and flask 1.1.3 and experiencing the same error, can someone suggest a work around for now, that would be much appreciated!
I'm using conan in python 3.7 up to 3.10 and this issue breaks conan. Please stick to semantic versioning and don't make breaking changes in minor version updates!
2.0.1
I am using python:3.7 and flask 1.1.3 and experiencing the same error, can someone suggest a work around for now, that would be much appreciated!
Set the version to 2.0.1
in your requirements.txt or install it with python -m pip install markupsafe==2.0.1
worked for me after adding markupsafe==2.0.1 in requirements.txt
Duplicate of #282
You are using an unsupported version of Jinja, please update to the latest version. Additionally, please read https://hynek.me/articles/semver-will-not-save-you/, then use a tool like pip-tools to pin your dependencies and control when you get updates. Be sure to run your tests with deprecation warnings treated as errors so that you get notified of these types of changes early.
Removing deprecated functions nevertheless requires a major release. Semantic versioning won't save us, but we don't have to artificially worsen the situation by not following the basic rules.
This error surfaces on Python 3.7.12, Flask 1.1.4 and MarkupSafe 2.0.1. So it is not resolved.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/local/lib/python3.7/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/local/lib/python3.7/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/local/lib/python3.7/site-packages/spacy/__init__.py", line 14, in <module>
from .cli.info import info # noqa: F401
File "/usr/local/lib/python3.7/site-packages/spacy/cli/__init__.py", line 20, in <module>
from .init_config import init_config, fill_config # noqa: F401
File "/usr/local/lib/python3.7/site-packages/spacy/cli/init_config.py", line 8, in <module>
from jinja2 import Template
File "/usr/local/lib/python3.7/site-packages/jinja2/__init__.py", line 12, in <module>
from .environment import Environment
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 25, in <module>
from .defaults import BLOCK_END_STRING
File "/usr/local/lib/python3.7/site-packages/jinja2/defaults.py", line 3, in <module>
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
File "/usr/local/lib/python3.7/site-packages/jinja2/filters.py", line 13, in <module>
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py
Did you read the comments? You need to pin your dependencies or update to the latest Jinja version.
I am getting the same error even though I have the latest Jinja2 and MarkUpSafe==2.0.1:
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/init.py)
What can I do to fix this. I am trying to run an airflow pipeline. Full error log below:
Traceback (most recent call last):
File "/usr/local/bin/airflow", line 25, in
from airflow.configuration import conf
File "/usr/local/lib/python3.7/site-packages/airflow/init.py", line 42, in
from airflow.models import DAG
File "/usr/local/lib/python3.7/site-packages/airflow/models/init.py", line 21, in
from airflow.models.baseoperator import BaseOperator, BaseOperatorLink # noqa: F401
File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 36, in
import jinja2
File "/usr/local/lib/python3.7/site-packages/jinja2/init.py", line 33, in
from jinja2.environment import Environment, Template
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in
from jinja2 import nodes
File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in
from jinja2.utils import Markup
File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in
from markupsafe import Markup, escape, soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/init.py)