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

[CT-255] [Bug] ImportError: cannot import name soft_unicode from markupsafe #4745

Closed
1 task done
sumit-sampang-rai opened this issue Feb 18, 2022 · 6 comments · Fixed by #4746
Closed
1 task done
Labels
bug Something isn't working dependencies Changes to the version of dbt dependencies

Comments

@sumit-sampang-rai
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Markup recently released its new version 2.1.0 which is essential for Jinja2 package. Jinja has already released version 3.x.x and dbt still uses version 2.x.x and their developers won't support 2.x.x for some time. Now the command dbt deps throws an error.

Expected Behavior

While running dbt deps the packages should install instead of throwing errors.

Steps To Reproduce

No response

Relevant log output

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.12/x64/bin/dbt", line 5, in <module>
    from dbt.main import main
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/dbt/main.py", line 11, in <module>
    import dbt.version
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/dbt/version.py", line 11, in <module>
    import dbt.semver
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/dbt/semver.py", line 8, in <module>
    import dbt.utils
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/dbt/utils.py", line 9, in <module>
    import jinja2
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/jinja2/__init__.py", line 12, in <module>
    from .environment import Environment
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/jinja2/environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/jinja2/defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/jinja2/filters.py", line 13, in <module>
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markupsafe/__init__.py)
Error: Process completed with exit code 1.

Environment

- OS: MacOS Monterey 12.2
- Python: 3.9.6
- dbt: 1.0.1

What database are you using dbt with?

snowflake

Additional Context

No response

@sumit-sampang-rai sumit-sampang-rai added bug Something isn't working triage labels Feb 18, 2022
@github-actions github-actions bot changed the title [Bug] ImportError: cannot import name 'soft_unicode' from 'markupsafe' [CT-255] [Bug] ImportError: cannot import name soft_unicode from markupsafe Feb 18, 2022
@sumit-sampang-rai
Copy link
Author

If someone is facing this error and need an urgent fix for your CI/CD or job in production, you can downgrade your MarkupSafe into version 2.0.1 manually. If you installed dbt-core with pip then you can run pip3 install --force-reinstall MarkupSafe==2.0.1

@abhinav-kumar-17
Copy link

If building from source(pip install .), the Jinja2 version can be bumped to 3.0.3 as well in the .core/setup.py. This does include some breaking changes in Jinja2

@scottpaulin
Copy link

Steps to reproduce

Building this Dockerfile reproduces the error

FROM ubuntu:20.04
# Pip e.t.c.
RUN apt-get update -y && apt-get install -y python3-pip python3-dev build-essential

# Install system requirements https://docs.getdbt.com/dbt-cli/install/pip#ubuntudebian
RUN apt-get install -y git libpq-dev python-dev python3-pip
RUN apt-get remove python-cffi
RUN pip install --upgrade cffi
RUN pip install cryptography~=3.4

# RUN pip install MarkupSafe==2.0.1

RUN pip install dbt-core

# python 3.8
RUN python3 --version

# Offending line
RUN dbt --version

ENTRYPOINT ["echo", "Hello, World"]

@yu-iskw
Copy link
Contributor

yu-iskw commented Feb 18, 2022

MEMO: pallets/jinja#1587

@ftupas
Copy link

ftupas commented Feb 18, 2022

If someone is facing this error and need an urgent fix for your CI/CD or job in production, you can downgrade your MarkupSafe into version 2.0.1 manually. If you installed dbt-core with pip then you can run pip3 install --force-reinstall MarkupSafe==2.0.1

Thanks, had this issue in our CI/CD and it worked liked a charm!

@jtcohen6
Copy link
Contributor

jtcohen6 commented Feb 18, 2022

Thanks for opening @mailtosumitrai, and for weighing in everyone! I think our approach here will need to look like:

  • Pinning MarkupSafe==2.0.1 in our production environments, and in the next patch release of dbt (v1.0.2, currently available as a release candidate)
  • Looking into whether we can safely upgrade to Jinja3 in an upcoming minor version. We've hesitated to do this, given the risk of breaking changes to user/project code—but we need to weigh that against the risk of running into this type of dependency/installation issue, given that Jinja2 is no longer officially supported and won't be patched accordingly.

@jtcohen6 jtcohen6 added dependencies Changes to the version of dbt dependencies and removed triage labels Feb 18, 2022
robastel added a commit to Dashlane/dbt-invoke that referenced this issue Feb 21, 2022
Signed-off-by: Robert Astel <rob.astel@gmail.com>
robastel added a commit to Dashlane/dbt-invoke that referenced this issue Feb 21, 2022
* Use all supported_resource_types by default

Signed-off-by: Robert Astel <rob.astel@gmail.com>

* Handle mutual exclusivity between resource_type and model arguments

Signed-off-by: Robert Astel <rob.astel@gmail.com>

* Pin MarkupSafe==2.0.1 for dbt-core<1.0.0 due to dbt-labs/dbt-core#4745

Signed-off-by: Robert Astel <rob.astel@gmail.com>
adamtwo pushed a commit to Teradata/dbt-teradata that referenced this issue Mar 14, 2022
adamantike added a commit to adamantike/dbt-core that referenced this issue Apr 12, 2022
The current `MarkupSafe` pinned version has been added in dbt-labs#4746 as a
temporary fix for dbt-labs#4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53
ChenyuLInx pushed a commit that referenced this issue Apr 13, 2022
* Flexibilize MarkupSafe pinned version

The current `MarkupSafe` pinned version has been added in #4746 as a
temporary fix for #4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53
VersusFacit pushed a commit that referenced this issue Apr 14, 2022
* Flexibilize MarkupSafe pinned version

The current `MarkupSafe` pinned version has been added in #4746 as a
temporary fix for #4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53
leahwicz pushed a commit that referenced this issue Apr 18, 2022
* Flexibilize MarkupSafe pinned version

The current `MarkupSafe` pinned version has been added in #4746 as a
temporary fix for #4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53
leahwicz pushed a commit that referenced this issue Apr 19, 2022
* Flexibilize MarkupSafe pinned version

The current `MarkupSafe` pinned version has been added in #4746 as a
temporary fix for #4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53
leahwicz added a commit that referenced this issue Apr 19, 2022
* Flexibilize MarkupSafe pinned version

The current `MarkupSafe` pinned version has been added in #4746 as a
temporary fix for #4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53

Co-authored-by: Michael Manganiello <adamantike@users.noreply.github.com>
leahwicz added a commit that referenced this issue May 9, 2022
* Flexibilize MarkupSafe pinned version

The current `MarkupSafe` pinned version has been added in #4746 as a
temporary fix for #4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53

Co-authored-by: Michael Manganiello <adamantike@users.noreply.github.com>
agoblet pushed a commit to BigDataRepublic/dbt-core that referenced this issue May 20, 2022
* Flexibilize MarkupSafe pinned version

The current `MarkupSafe` pinned version has been added in dbt-labs#4746 as a
temporary fix for dbt-labs#4745.

However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.

To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].

This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.

[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53
@emmyoop emmyoop mentioned this issue Aug 28, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Changes to the version of dbt dependencies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants