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

MarkupSafe 2.1.0 gives ImportError(soft_unicode) for Jinja2 2.11.3 #1587

Closed
seedhisadak opened this issue Feb 18, 2022 · 12 comments
Closed

MarkupSafe 2.1.0 gives ImportError(soft_unicode) for Jinja2 2.11.3 #1587

seedhisadak opened this issue Feb 18, 2022 · 12 comments

Comments

@seedhisadak
Copy link

seedhisadak commented Feb 18, 2022

Upon installing and using Jinja2==2.11.3, the dependency requirement is

MarkupSafe [required: >=0.23]

This installs the latest MarkupSafe==2.1.0 which gives the following error when using the Jinja2 packages

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)

Note: This works fine with MarkupSafe 2.0.1

Environment:

  • Python version: 3.7.12
  • Jinja2 version: 2.11.3
@seedhisadak seedhisadak changed the title MarkupSafe 2.1.0 gives ImportError for Jinja2 2.11.3 MarkupSafe 2.1.0 gives ImportError(soft_unicode) for Jinja2 2.11.3 Feb 18, 2022
@vikas-getconnect
Copy link

We also start facing the same , downgrading the MarkupSafe==2.0.1 works fine for now

@KrennKristof
Copy link

They removed soft_unicode and one has to use soft_str instead.

https://markupsafe.palletsprojects.com/en/2.1.x/changes/#version-2-1-0

@memsharded
Copy link

They removed soft_unicode and one has to use soft_str instead.

Yes, but not something that consumers of Jinja2 2.11.3 can do right? We have tons of released versions in production that are locked on Jinja2 2.11, and releasing patches for all is going to be painful. A bit unexpected that MarkupSafe is breaking in this way in minor versions.

@seedhisadak
Copy link
Author

seedhisadak commented Feb 18, 2022

Wouldn't it be possible to fix the dependency to the below and republish Jinja2 2.11.3?

MarkupSafe [required: >=0.23, <=2.0.1]

@lasote
Copy link

lasote commented Feb 18, 2022

The jinja2 requirement MarkupSafe>=0.23 is a bit naive. Even if MarkupSafe breaks in a major version jinja2 will break.

@ivan2angelov
Copy link

ivan2angelov commented Feb 18, 2022

I have same problem. Please fix jinja2 markupsafe package dependency

@sumit-sampang-rai
Copy link

@ivan2angelov I created similar issue in #1585 and I got this answer

Jinja 2.x has not been supported for some time. Upgrade Jinja, and use something like pip-tools to pin your dependencies.

juanjo-nan added a commit to NaN-tic/tryton-config that referenced this issue Feb 18, 2022
juanjo-nan added a commit to NaN-tic/tryton-config that referenced this issue Feb 18, 2022
juanjo-nan added a commit to NaN-tic/tryton-config that referenced this issue Feb 18, 2022
@heikkima
Copy link

#1589

@EnricoRiccardi

This comment was marked as off-topic.

@seedhisadak
Copy link
Author

seedhisadak commented Feb 18, 2022

Quick note, to fix our pipelines we just pinned the MarkupSafe version in our requirements file, example requirements.txt file

Flask==1.1.4
MarkupSafe==2.0.1  # required is >=0.23 but latest 2.1.0 gives import error

@aditya-kar
Copy link

Quick note, to fix our pipelines we just pinned the MarkupSafe version in our requirements file, example requirements.txt file

Flask==1.1.4
MarkupSafe==2.0.1  # required is >=0.23 but latest 2.1.0 gives import error

We did the same and we'll probably start using pip-tools to pin all dependencies going forward.

MarkupSafe~=2.0.1

@davidism
Copy link
Member

davidism commented Feb 18, 2022

Duplicate of #1585

You are using an unsupported version of the project, 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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2022
wadevries added a commit to wadevries/pcloadletter that referenced this issue Oct 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests