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

jinja2.exceptions.UndefinedError: 'bootstrap_find_resource' is undefined

Open nmaas87 opened this issue 5 years ago • 7 comments

I checked out the Flask Web Development section about Bootstrap ( https://github.com/miguelgrinberg/flasky/tree/3e ) and tried to run it and got this error:

File "C:\Program Files (x86)\Python37-32\lib\site-packages\flask_bootstrap\templates\bootstrap\base.html", line 15, in block "styles"
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    {%- endblock metas %}
 
    {%- block styles %}
    <!-- Bootstrap -->
    <link href="{{bootstrap_find_resource('css/bootstrap.css', cdn='bootstrap')}}" rel="stylesheet">
    {%- endblock styles %}
    {%- endblock head %}
  </head>
  <body{% block body_attribs %}{% endblock body_attribs %}>
    {% block body -%}
jinja2.exceptions.UndefinedError: 'bootstrap_find_resource' is undefined

Python Version: 3.7.3, 32 bit

Pip Freeze:

altgraph==0.16.1
arrow==0.13.1
astroid==2.2.5
attrs==19.1.0
Bootstrap-Flask==1.0.10
certifi==2019.3.9
chardet==3.0.4
Click==7.0
colorama==0.4.1
dateparser==0.7.1
decorator==4.4.0
docopt==0.6.2
dominate==2.3.5
Flask==0.12.4
flask-appconfig==0.11.1
Flask-Bootstrap==3.3.7.1
Flask-Debug==0.4.3
Flask-Moment==0.7.0
flask-nav==0.6
Flask-Script==2.0.6
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
future==0.17.1
hachoir==3.0a5
hachoir3==3.0a2
idna==2.8
inflection==0.3.1
ipython-genutils==0.2.0
isort==4.3.17
itsdangerous==1.1.0
Jinja2==2.10.1
json2html==1.2.1
json2table==1.1.5
jsonschema==3.0.1
jupyter-core==4.4.0
lazy-object-proxy==1.3.1
macholib==1.11
MarkupSafe==1.1.1
mccabe==0.6.1
moment==0.8.2
nbformat==4.4.0
numpy==1.16.2
pefile==2018.8.8
pipreqs==0.4.9
plotly==3.7.1
PyFladesk==1.0
PyInstaller==3.4
pylint==2.3.1
pymediainfo==4.0
PyQt5==5.12.1
PyQt5-sip==4.19.15
PyQtWebEngine==5.12.1
pyrsistent==0.14.11
python-dateutil==2.8.0
pytz==2018.9
pywin32-ctypes==0.2.0
regex==2019.4.14
repoze.lru==0.7
requests==2.21.0
retrying==1.3.3
Routes==2.4.1
six==1.12.0
SQLAlchemy==1.3.2
times==0.7
traitlets==4.3.2
typed-ast==1.3.1
tzlocal==1.5.1
urllib3==1.24.1
visitor==0.1.3
vispy==0.5.3
Werkzeug==0.15.2
wrapt==1.11.1
WTForms==2.2.1
yarg==0.1.9

Any ideas? :)

nmaas87 avatar Apr 14 '19 12:04 nmaas87

It does work on Python 3.6.8, but it seems it broke on Python 3.7.x

nmaas87 avatar Apr 16 '19 10:04 nmaas87

Facing the same issue using Python 3.7.x. Were you able to solve this error @nmaas87 on 3.7.x

TanveshT avatar Apr 06 '20 03:04 TanveshT

No @TanveshT - never was able to, error still persists

nmaas87 avatar Apr 06 '20 04:04 nmaas87

I feel like a genius right now. clap for me please. I was able to solve this by uninstall bootstrap-flask and reinstalling the latest version of flask-bootstrap 3.3.7.1

rextech03 avatar Apr 17 '20 16:04 rextech03

Bootstrap-Flask can't work together with Flask-Bootstrap, you have to uninstall them then reinstall Flask-Bootstrap:

$ pip uninstall bootstrap-flask flask-bootstrap
$ pip install flask-bootstrap

Sorry for the inconvenience, to follow Flask's extension development rule, I have to name the package of Bootstrap-Flask in a format like flask_xxx (i.e. flask_bootstrap), that's the same package name of Flask-Bootstrap. It's too late when I realize this conflict :(

greyli avatar Apr 19 '20 00:04 greyli

It works for me, thanks alot @greyli

tangzzz-fan avatar Dec 18 '20 07:12 tangzzz-fan

while hosting on render i got this error how did you solve it??

Abhijeet2121 avatar Jul 27 '23 18:07 Abhijeet2121