Forums

Bootstrap Components

Hi all, I'm trying to develop a web page using boostrap components in PythonAnywhere (with python3.6, Dash and Flask), using the following simple example.

import dash import dash_bootstrap_components as dbc app = dash.Dash( external_stylesheets=[dbc.themes.BOOTSTRAP] ) app.layout = dbc.Alert( "Hello, Bootstrap!" className="m-5" )

I have loaded all necessary modules (plotly, dash, dash_bootstrap_components) and the script runs under the bash console, but I keep getting a "Something went wrong :-(" error when trying to compile it into a web page. Any ideas what I'm missing? I have, in the past, successfully turn into a webpage code which didn't use bootstrap, so i was wondering whether bootstrap components are supported or not.

Look in your error and server logs for tracebacks that you can use to start debugging the "Something went wrong" error.

Does pythonanywhere support Bootstrap? On pip install it says it does not.

bootstrap is not a Python package so it's not on PyPI and so you cannot install it with pip. See the bootstrap documentation

@glenn: can you elaborate?

I am able to install dash_bootstrap_components using pip. (https://pypi.org/project/dash-bootstrap-components/).

Will I be able to use it for a dash app?

yes you can use bootstrap, but it is not installed using pip.

Hi, I have installed the dash_bootstrap_components using pip install dash-bootstrap-components --user on bash console. Then I tried to check, if it works on python console with import dash_bootstrap_components and I received no errors. In my script I "import dash_bootstrap_components as dbc" to use its layout components, but I get the error: ModuleNotFoundError: No module named 'dash_bootstrap_components'

I have fixed it with:

pip3.7 install dash_bootstrap_components --user

because I use Python 3.7 now it works.

Good to know you figured that out!

Thanks for finding the solution! Helps a lot.

Glad to hear that it works for you.