ModuleNotFoundError: No module named 'flask.ext'
nuaays opened this issue ยท 12 comments
ERROR in Python3.6
from flask.ext.cache import make_template_fragment_key
File "/usr/local/lib/python3.6/site-packages/flask_cache/__init__.py", line 156, in init_app
from .jinja2ext import CacheExtension, JINJA_CACHE_ATTR_NAME
File "/usr/local/lib/python3.6/site-packages/flask_cache/jinja2ext.py", line 33, in <module>
from flask.ext.cache import make_template_fragment_key
Solution: change flask.ext.cache to flask_cache line33
line33: from flask_cache import make_template_fragment_key
#from flask.ext.cache import make_template_fragment_key
Using from flask_cache import make_template_fragment_key
instead. flask.ext.___
style is deprecated.
This is broken in here: https://github.com/thadeusb/flask-cache/blob/master/flask_cache/jinja2ext.py#L33
Use flaskext.cache
Here's a q&d fix for the issue:
sed -i 's/flask.ext.cache/flask_cache/g' flask_cache/__init__.py flask_cache/jinja2ext.py test_cache.py docs/index.rst
Use Flask-Caching instead https://github.com/sh4nks/flask-caching
#192 has a pr for this
cache.init_app(backend)
File "/Users/steven/.pyenv/versions/3.5.3/lib/python3.5/site-packages/flask_cache/init.py", line 156, in init_app
from .jinja2ext import CacheExtension, JINJA_CACHE_ATTR_NAME
File "/Users/steven/.pyenv/versions/3.5.3/lib/python3.5/site-packages/flask_cache/jinja2ext.py", line 33, in
from flask.ext.cache import make_template_fragment_key
ImportError: No module named 'flask.ext'
Use Flask-Caching instead https://github.com/sh4nks/flask-caching
Fix for pip3
still not fixed!
line33:
from flask_cache import make_template_fragment_key
It works perfectly for me!
Python 3.6
Flask 1.0.2
Thank you.
@frispete suggestion worked for me mostly
sed -i 's/flask.ext.cache/flask_cache/g' flask_cache/__init__.py flask_cache/jinja2ext.py
were the succeeding commands.