Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

"jinja2 has no attribute Markup" error on generating config after clean install from pip. #12292

Closed
michaelkaye opened this issue Mar 24, 2022 · 4 comments · Fixed by #12289
Closed

Comments

@michaelkaye
Copy link
Contributor

Description

  File "/Users/runner/work/element-android/element-android/synapse/env/lib/python3.8/site-packages/synapse/push/mailer.py", line 870, in <module>
    def safe_markup(raw_html: str) -> jinja2.Markup:
AttributeError: module 'jinja2' has no attribute 'Markup'
Error: The process '/Users/runner/work/element-android/element-android/synapse/env/bin/python3' failed with exit code 1

Steps to reproduce

/bin/mkdir -p synapse
/Users/runner/hostedtoolcache/Python/3.8.12/x64/bin/python -m venv env
/Users/runner/work/element-android/element-android/synapse/env/bin/pip install -q --upgrade pip
/Users/runner/work/element-android/element-android/synapse/env/bin/pip install -q --upgrade setuptools
/Users/runner/work/element-android/element-android/synapse/env/bin/pip install -q matrix-synapse
Generating config...
/Users/runner/work/element-android/element-android/synapse/env/bin/python3 -m synapse.app.homeserver --server-name localhost --config-path homeserver.yaml --generate-config --report-stats=no
Traceback (most recent call last):
  File "/Users/runner/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/runner/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/runner/work/element-android/element-android/synapse/env/lib/python3.8/site-packages/synapse/app/homeserver.py", line 39, in <module>
    from synapse.app import _base
  File "/Users/runner/work/element-android/element-android/synapse/env/lib/python3.8/site-packages/synapse/app/_base.py", line 59, in <module>
    from synapse.events.spamcheck import load_legacy_spam_checkers
  File "/Users/runner/work/element-android/element-android/synapse/env/lib/python3.8/site-packages/synapse/events/spamcheck.py", line 31, in <module>
    from synapse.rest.media.v1._base import FileInfo
  File "/Users/runner/work/element-android/element-android/synapse/env/lib/python3.8/site-packages/synapse/rest/__init__.py", line 19, in <module>
    from synapse.rest.client import (
  File "/Users/runner/work/element-android/element-android/synapse/env/lib/python3.8/site-packages/synapse/rest/client/account.py", line 42, in <module>
    from synapse.push.mailer import Mailer
  File "/Users/runner/work/element-android/element-android/synapse/env/lib/python3.8/site-packages/synapse/push/mailer.py", line 870, in <module>
    def safe_markup(raw_html: str) -> jinja2.Markup:
AttributeError: module 'jinja2' has no attribute 'Markup'
Error: The process '/Users/runner/work/element-android/element-android/synapse/env/bin/python3' failed with exit code 1

Version information

  • Version:
    Latest from pip

  • Install method:
    pip

  • Platform:
    github hosted macos runner

Additional information:

I can replicate locally with the above commands.

michaelk@michaelk-XPS-13-9370:~$ venv/bin/pip freeze
attrs==21.4.0
Automat==20.2.0
bcrypt==3.2.0
bleach==4.1.0
canonicaljson==1.6.0
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.12
constantly==15.1.0
cryptography==36.0.2
frozendict==2.3.0
hyperlink==21.0.0
idna==3.3
ijson==3.1.4
importlib-metadata==4.11.3
incremental==21.3.0
Jinja2==3.1.0
jsonschema==4.4.0
MarkupSafe==2.1.1
matrix-common==1.1.0
matrix-synapse==1.55.0
msgpack==1.0.3
netaddr==0.8.0
packaging==21.3
phonenumbers==8.12.45
Pillow==9.0.1
prometheus-client==0.13.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pymacaroons==0.13.0
PyNaCl==1.5.0
pyOpenSSL==22.0.0
pyparsing==3.0.7
pyrsistent==0.18.1
PyYAML==6.0
requests==2.27.1
service-identity==21.1.0
signedjson==1.1.1
simplejson==3.17.6
six==1.16.0
sortedcontainers==2.4.0
treq==22.2.0
Twisted==22.2.0
typing-extensions==4.1.1
unpaddedbase64==2.1.0
urllib3==1.26.9
webencodings==0.5.1
zipp==3.7.0
zope.interface==5.4.0

https://pypi.org/project/Jinja2/#history released 3.1.0 about 4h ago

@michaelkaye
Copy link
Contributor Author

probably pallets/jinja#1544

-   ``Markup`` and ``escape`` should be imported from MarkupSafe.

@squahtx
Copy link
Contributor

squahtx commented Mar 24, 2022

Fixed in #12289, which should make it to PyPI within a day or two.

@clokep
Copy link
Member

clokep commented Mar 24, 2022

I think we can close this now that v1.55.1 is out with the fix? Docker builds and such are probably forthcoming still though...

@DMRobertson
Copy link
Contributor

If one is unable to use the patch in #12289 (e.g. to reproduce something based on an old version of Synapse), you can workaround this by using the last release of Jinja2 prior to this change, with e.g. pip install Jinja2==3.0.3 in the appropriate Python environment

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants