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

ImportError: cannot import name 'escape' from 'jinja2' #489

Open
sssemil opened this issue Apr 2, 2022 · 7 comments
Open

ImportError: cannot import name 'escape' from 'jinja2' #489

sssemil opened this issue Apr 2, 2022 · 7 comments

Comments

@sssemil
Copy link

sssemil commented Apr 2, 2022

If you try running python backtest.py, you will get this error:

Traceback (most recent call last):
  File "/home/emil/Projects/binance-trade-bot/backtest.py", line 3, in <module>
    from binance_trade_bot import backtest
  File "/home/emil/Projects/binance-trade-bot/binance_trade_bot/__init__.py", line 1, in <module>
    from .backtest import backtest
  File "/home/emil/Projects/binance-trade-bot/binance_trade_bot/backtest.py", line 8, in <module>
    from .binance_api_manager import BinanceAPIManager
  File "/home/emil/Projects/binance-trade-bot/binance_trade_bot/binance_api_manager.py", line 10, in <module>
    from .binance_stream_manager import BinanceCache, BinanceOrder, BinanceStreamManager, OrderGuard
  File "/home/emil/Projects/binance-trade-bot/binance_trade_bot/binance_stream_manager.py", line 9, in <module>
    from unicorn_binance_websocket_api import BinanceWebSocketApiManager
  File "/home/emil/Projects/binance-trade-bot/venv/lib/python3.10/site-packages/unicorn_binance_websocket_api/__init__.py", line 3, in <module>
    from unicorn_binance_websocket_api.manager import BinanceWebSocketApiManager
  File "/home/emil/Projects/binance-trade-bot/venv/lib/python3.10/site-packages/unicorn_binance_websocket_api/manager.py", line 40, in <module>
    from unicorn_binance_websocket_api.restserver import BinanceWebSocketApiRestServer
  File "/home/emil/Projects/binance-trade-bot/venv/lib/python3.10/site-packages/unicorn_binance_websocket_api/restserver.py", line 36, in <module>
    from flask_restful import Resource
  File "/home/emil/Projects/binance-trade-bot/venv/lib/python3.10/site-packages/flask_restful/__init__.py", line 3, in <module>
    from flask import request, url_for, current_app
  File "/home/emil/Projects/binance-trade-bot/venv/lib/python3.10/site-packages/flask/__init__.py", line 14, in <module>
    from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/home/emil/Projects/binance-trade-bot/venv/lib/python3.10/site-packages/jinja2/__init__.py)

Similar issue in another project - pallets/flask#4494

@sssemil
Copy link
Author

sssemil commented Apr 2, 2022

Specify this in your requirements.txt as a workaround:

jinja2==3.0.3
flask==1.1.1

@znake77
Copy link

znake77 commented Apr 2, 2022

Hi had the same issue so i tried your workaround but it gives me now another error:

Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.8/runpy.py", line 144, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/home/user/Documents/binance-bot/binance-trade-bot/binance_trade_bot/__init__.py", line 1, in <module>
    from .backtest import backtest
  File "/home/user/Documents/binance-bot/binance-trade-bot/binance_trade_bot/backtest.py", line 8, in <module>
    from .binance_api_manager import BinanceAPIManager
  File "/home/user/Documents/binance-bot/binance-trade-bot/binance_trade_bot/binance_api_manager.py", line 10, in <module>
    from .binance_stream_manager import BinanceCache, BinanceOrder, BinanceStreamManager, OrderGuard
  File "/home/user/Documents/binance-bot/binance-trade-bot/binance_trade_bot/binance_stream_manager.py", line 9, in <module>
    from unicorn_binance_websocket_api import BinanceWebSocketApiManager
  File "/home/user/Documents/binance-bot/binance-trade-bot/venv/lib/python3.8/site-packages/unicorn_binance_websocket_api/__init__.py", line 3, in <module>
    from unicorn_binance_websocket_api.unicorn_binance_websocket_api_manager import BinanceWebSocketApiManager
  File "/home/user/Documents/binance-bot/binance-trade-bot/venv/lib/python3.8/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_manager.py", line 40, in <module>
    from .unicorn_binance_websocket_api_restserver import BinanceWebSocketApiRestServer
  File "/home/user/Documents/binance-bot/binance-trade-bot/venv/lib/python3.8/site-packages/unicorn_binance_websocket_api/unicorn_binance_websocket_api_restserver.py", line 36, in <module>
    from flask_restful import Resource
  File "/home/user/Documents/binance-bot/binance-trade-bot/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 3, in <module>
    from flask import request, url_for, current_app
  File "/home/user/Documents/binance-bot/binance-trade-bot/venv/lib/python3.8/site-packages/flask/__init__.py", line 21, in <module>
    from .app import Flask
  File "/home/user/Documents/binance-bot/binance-trade-bot/venv/lib/python3.8/site-packages/flask/app.py", line 32, in <module>
    from werkzeug.wrappers import BaseResponse
ImportError: cannot import name 'BaseResponse' from 'werkzeug.wrappers' (/home/user/Documents/binance-bot/binance-trade-bot/venv/lib/python3.8/site-packages/werkzeug/wrappers/__init__.py)

@znake77
Copy link

znake77 commented Apr 2, 2022

For those having this issue is because the last version of Werkzeug are not compatible.
Ref: postmanlabs/httpbin#673

Solved this issue with :
pip install Werkzeug==2.0.3

@Mundo-Desconocido
Copy link

For those having this issue is because the last version of Werkzeug are not compatible. Ref: postmanlabs/httpbin#673

Solved this issue with : pip install Werkzeug==2.0.3

it doesn't work either

@B-Mbengue
Copy link

There are some updates on Jinja2 package. To solve the issue change in the "requirements" the flask version to flask=2.1.0 and re-run the code

@ekurer
Copy link

ekurer commented Apr 15, 2022

Hey @edeng23 can you update requirements? Or should I submit a PR?

@edeng23
Copy link
Owner

edeng23 commented Apr 15, 2022

Can you please submit a PR?

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

6 participants