Hi Payton. Thanks for your response. I maybe should have mentioned that I’ve tried a couple of versions of Python, always in a virtualenv. I hadn’t, however, created a fresh virtualenv just to test this issue. So I did that. Unfortunately, I get the same result.
My code is exactly the table example in Part 2 of the tutorial, under the section head “Reusable Components”. Here’s the code:
# Run this app with `python app.py` and
# visit http://127.0.0.1:8050/ in your web browser.
from dash import Dash, html
import pandas as pd
df = pd.read_csv('https://gist.githubusercontent.com/chriddyp/c78bf172206ce24f77d6363a2d754b59/raw/c353e8ef842413cae56ae3920b8fd78468aa4cb2/usa-agricultural-exports-2011.csv')
def generate_table(dataframe, max_rows=10):
return html.Table([
html.Thead(
html.Tr([html.Th(col) for col in dataframe.columns])
),
html.Tbody([
html.Tr([
html.Td(dataframe.iloc[i][col]) for col in dataframe.columns
]) for i in range(min(len(dataframe), max_rows))
])
])
app = Dash(__name__)
app.layout = html.Div([
html.H4(children='US Agriculture Exports (2011)'),
generate_table(df)
])
if __name__ == '__main__':
app.run_server(debug=True)
And here’s a complete blow-by-blow starting with building a new virtualenv and ending with a running app:
*[main][~/tmp]$ mkdir dash_example
*[main][~/tmp]$ cd dash_example
*[main][~/tmp/dash_example]$ python --version
Python 3.10.6
*[main][~/tmp/dash_example]$ virtualenv env
/usr/local/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
created virtual environment CPython3.9.14.final.0-64 in 456ms
creator CPython3Posix(dest=/Users/steve/tmp/dash_example/env, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/steve/Library/Application Support/virtualenv)
added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
*[main][~/tmp/dash_example]$ source env/bin/activate
(env) *[main][~/tmp/dash_example]$ pip install dash
Collecting dash
Using cached dash-2.6.2-py3-none-any.whl (9.8 MB)
Collecting flask-compress
...
Successfully installed Flask-2.2.2 Jinja2-3.1.2 MarkupSafe-2.1.1 Werkzeug-2.2.2 brotli-1.0.9 click-8.1.3 dash-2.6.2 dash-core-components-2.0.0 dash-html-components-2.0.0 dash-table-5.0.0 flask-compress-1.13 importlib-metadata-5.0.0 itsdangerous-2.1.2 plotly-5.10.0 tenacity-8.1.0 zipp-3.9.0
...
(env) *[main][~/tmp/dash_example]$ pip install pandas
...
Successfully installed numpy-1.23.4 pandas-1.5.0 python-dateutil-2.8.2 pytz-2022.5 six-1.16.0
...
(env) *[main][~/tmp/dash_example]$ vi app.py
(env) *[main][~/tmp/dash_example]$ python app.py
Dash is running on http://127.0.0.1:8050/
* Serving Flask app 'app'
* Debug mode: on
Hitting http://127.0.0.1:8050
with my browser leads to the same yucky results I showed in my original post.
Just for yucks, I created another virtualenv based on Python 3.8 and did exactly what I show above. Same result.
WT*?