How to Install and start with Dash on Debian 11 Bullseye – Guide

Dash is a Plotly framework for programming web applications for data analysis / visualization in Python, R or Julia. Dash is based on React, a popular Javascript web framework, and Flask, one of the most famous Python web servers. Plotly also offers commercial solutions for hosting web applications, however, as Dash is completely free and open source, you can install it on your own server with Python support. Install and use Dash Plotly on Debian 11 Bullseye server Here in the tutorial, we will learn the installation process on the Debian 11 server and how to create a Dash application project.

Requirements:

1. Run system update

The first thing we should do before installing any packages is to run the system update command. This ensures that existing packages are up so far and also rebuilds the system repository cache. sudo apt update

2. Install Python and Pip

Although a full server comes with Python 3 out of the box, the minimal server wouldn’t. So to install and set up Dash, first install Python and Pip 3. sudo apt install python3 python3-pip

3. Install Dash using Pip or Anaconda

Well here we are using pip to set up Dash in Debian 11, however, if you are already an Anaconda user then you can use the Conda package manager to get this Plotly framework. Note: Learn the steps to install Anaconda on Debian 10 or 11 Bullseye. To get Dash HTML, core components including Plotly using PIP, run: pip install dash Whereas for front-end pip install dash-renderer Fun facts: if you are using Anaconda, get it from its GUI or use the command: count install dash

4. Create your first Dash project on Debian 11

Create a project folder, say myproject mkdir myproject Switch to it: cd my project Create a python file, say – first_app.py. nano first_app.py Let’s first create a simple HTML page using DASH to display some text we want, for example: “Here is my first Dash project” In the file, paste the lines provided below. With which we are importing the HMTL components from Dash, directing to display the text in the H1 header, and also in the final from the file we declare a code to start the server in the main routine. import trace import dash_html_components as html app = dash.Dash(name) app.layout = html.H1 (children = “Here’s my first Dash project!”) if name == “main”: app.run_server (debug = True) Create the first Dash Plotly app on Debian 11 Save the file by pressing Ctrl + O, press the Enter key and, to exit, use – Ctrl + X. Run the Python application file above: Now, use Python to run the file created above: python3 first_app.py Run your Dash app using python Access the Dash app When you run the first Dash app you created, you’ll see the URL to access it. By default this will be 127.0.0.1 on port 8050. http://127.0.0.1:8050 Access App Python in browser

5. To run Dash on HTTP port

As we know, by default the Dash server runs on port 8050 and if you want to run it on some custom or, say, on HTTP port 8080. So, in the code, we used to start the server, set the port number. You can also set a specific IP address to use if needed. if name == ‘main’: app.run_server (host = ‘0.0.0.0 ′, debug = True, port = 80) Demonstration Histogram Project To go one step further to see something interactive in the Dash app, create a new app file and add the following code. nano new_app.py Paste the following code: import trace import dash_core_components as dcc import dash_html_components as html import plotly.express as px import pandas as pd app = dash.Dash (__ name__)

suppose you have a “long format” data frame

see https://plotly.com/python/px-arguments/ for more options

df = pd.DataFrame ({ “Fruit”: [“Apples”, “Oranges”, “Bananas”, “Apples”, “Oranges”, “Bananas”], “Amount”: [4, 1, 2, 2, 4, 5], “City”: [“SF”, “SF”, “SF”, “Montreal”, “Montreal”, “Montreal”] }) fig = px.bar (df, x = ”Fruit”, y = ”Quantity”, color = ”City”, bar mode = ”group”) app.layout = html.Div (children =[ html.H1(children=’Hello Dash’), html.Div(children=”’ Dash: A web application framework for your data. ”’), dcc.Graph( id=’example-graph’, figure=fig ) ]) if name == ‘main’: app.run_server (debug = True) Save the file by pressing Ctrl + O, press the Enter key and, to exit, use – Ctrl + X. Run the created application file: python3 new_app.py Now, go to your browser and connect to your server. Install and run the Dash Plotly graph on the Debian 11 server Error: python dash address Oserror Errno 98 already in use If you have closed the current Dash Server session and then run any other application on the terminal with an error – the address is already in use. Then just run the command given below, this will shut down all current python services running. kill -9 $ (ps -A | grep python | awk ‘{print $1}’)

Final note

I hope you like the guide How to Install and start with Dash on Debian 11 Bullseye. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.

How to Install and start with Dash on Debian 11 Bullseye  2022  - 55How to Install and start with Dash on Debian 11 Bullseye  2022  - 92How to Install and start with Dash on Debian 11 Bullseye  2022  - 65How to Install and start with Dash on Debian 11 Bullseye  2022  - 53