flask-cache icon indicating copy to clipboard operation
flask-cache copied to clipboard

ModuleNotFoundError: No module named 'flask.ext'

Open nuaays opened this issue 7 years ago • 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

nuaays avatar May 10 '18 03:05 nuaays

Using from flask_cache import make_template_fragment_key instead. flask.ext.___ style is deprecated.

winterjung avatar May 10 '18 14:05 winterjung

This is broken in here: https://github.com/thadeusb/flask-cache/blob/master/flask_cache/jinja2ext.py#L33

jpds avatar May 10 '18 16:05 jpds

Relevant: #189, #187, #185, #184, #182, #169, #166.

jpds avatar May 10 '18 16:05 jpds

Use flaskext.cache

Benjacho avatar May 26 '18 17:05 Benjacho

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

frispete avatar Jun 04 '18 10:06 frispete

Use Flask-Caching instead https://github.com/sh4nks/flask-caching

zoltan-fedor avatar Jun 28 '18 18:06 zoltan-fedor

#192 has a pr for this

allanice001 avatar Jul 26 '18 10:07 allanice001

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'

worldwar2008 avatar Aug 10 '18 16:08 worldwar2008

Use Flask-Caching instead https://github.com/sh4nks/flask-caching

Fix for pip3

sitthykun avatar Nov 14 '18 19:11 sitthykun

still not fixed!

yangeren avatar Nov 19 '18 05:11 yangeren

line33: from flask_cache import make_template_fragment_key

It works perfectly for me! Python 3.6 Flask 1.0.2

Thank you.

jac0x avatar Dec 16 '18 13:12 jac0x

@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.

Lewiscowles1986 avatar Nov 19 '19 01:11 Lewiscowles1986