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

Pin markupsafe version in requirements.txt #57

Closed
Skylake-dev opened this issue May 21, 2022 · 8 comments
Closed

Pin markupsafe version in requirements.txt #57

Skylake-dev opened this issue May 21, 2022 · 8 comments

Comments

@Skylake-dev
Copy link

Skylake-dev commented May 21, 2022

When i was trying to run the application as explained in the readme there is an error on the following command

> flask run --port 8000
[.....]
ImportError: cannot import name 'soft_unicode' from 'markupsafe'

After searching online i found that there is a breaking change in the library that has been made recently that causes this issue.
Pinning the version in the requirements fixes the issue.
markupsafe==2.0.1

@tianshanchuan
Copy link

tianshanchuan commented May 21, 2022 via email

@satwikkansal
Copy link
Owner

hmm, is markupsafe being used by flask? or requests?

Those are the only two dependencies the project uses.

@Skylake-dev
Copy link
Author

here is the full traceback

(.venv) C:\test\python_blockchain_app>flask run --port 8000
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\test\python_blockchain_app\.venv\Scripts\flask.exe\__main__.py", line 4, in <module>
  File "C:\test\python_blockchain_app\.venv\lib\site-packages\flask\__init__.py", line 14, in <module>
    from jinja2 import escape
  File "C:\test\python_blockchain_app\.venv\lib\site-packages\jinja2\__init__.py", line 12, in <module>
    from .environment import Environment
  File "C:\test\python_blockchain_app\.venv\lib\site-packages\jinja2\environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "C:\test\python_blockchain_app\.venv\lib\site-packages\jinja2\defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "C:\test\python_blockchain_app\.venv\lib\site-packages\jinja2\filters.py", line 13, in <module>
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (C:\test\python_blockchain_app\.venv\lib\site-packages\markupsafe\__init__.py)

so markupsafe is a dependency of jinja2 that is a dependency of flask.

You can reproduce the issue following these steps:

  • clone repo and cd into the folder
  • create a clean python virtual environment python -m venv .venv
  • activate the environment .venv\Scripts\activate
  • install requirements pip install -r requirements.txt
  • set FLASK_APP as shown in the readme export FLASK_APP=node_server.py or set FLASK_APP=node_server.py on windows
  • start server flask run --port 8000 <-- this is the line that generates the above exception
    adding markupsafe==2.0.1 to requirements fixes the issue. This is because they made a breaking change in version 2.1 removing soft_unicode, see the issue that i linked in my original post.

@satwikkansal
Copy link
Owner

Got it, thanks for the details!

@ryan-rober
Copy link

  • flask run --port 8000

i added markupsafe==2.0.1 to requirements
then run command pip install -r requirements.txt, it's successful but still generate above exception

@tianshanchuan
Copy link

tianshanchuan commented Sep 27, 2022 via email

@Skylake-dev
Copy link
Author

@hwangzh are you sure that the correct version of markupsafe is installed? I just tried and it works.

@satwikkansal
Copy link
Owner

This has been fixed now, thanks all!

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

No branches or pull requests

4 participants