Deploying a python app with plotly dash and AWS elastic beanstalk

In a new folder on your laptop, create a virtual environment:

virtualenv env

Activate the virtual environment (on a Mac):

source env/bin/activate

Activate the virtual environment (this is for Windows):


Install plotly dash in your virtual environment:

pip install dash

Create a text file called requirements.txt with a list of programs required by your virtual environment, as follows:

pip freeze > requirements.txt

Create a python program called with the following Dash code. Note that two items in here — application = app.server and are specific to AWS Elastic Beanstalk. If you’re using a different deployment platform (like Heroku) you can follow the blog post I wrote here.

import dash
import dash_core_components as dcc
import dash_html_components as html
########### Initiate the app
external_stylesheets = ['']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
application = app.server
app.title='Dash on AWS EB!'
########### Set up the layout
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
This is Dash running on Elastic Beanstalk.
'data': [
{'x': ['left', 'center', 'right'], 'y': [3,7,6], 'type': 'bar', 'name': 'category 1'},
{'x': ['left', 'center', 'right'], 'y': [4,2,5], 'type': 'bar', 'name': 'category 2'},
'layout': {
'plot_bgcolor': 'lightgray',
'title': 'Graph Title',
'xaxis':{'title':'x-axis label'},
'yaxis':{'title':'y-axis label'},
########### Run the app
if __name__ == '__main__':, port=8080)

Try running your application locally, within the virtual environment, to make sure it’s okay:


You can navigate to that URL ( in your browser to confirm that the application runs smoothly. If it works you should see this:

You should now exit the virtual environment by typing deactivate in terminal.

The next step is to create a zip file containing the application and requirement files, as follows.

zip requirements.txt

You can of course also do this using Winzip and Finder (or Explorer if you’re on a PC):

Now log into AWS console, go to Elastic Beanstalk, and create a new application:

Give your new app a name and description, then click create:

You’ll see the following message: “No environments currently exist for this application.” Click “create one now.” Then select “Web server environment” as shown below.

In “Base Configuration”, choose “Python” from the list of preconfigured configurations:

Where it says “upload your code” select and upload the zip file you created earlier, and select “create environment”

After waiting a few minutes, you should see output like this:

Once the new environment transitions to “okay”, the URL of your app will be displayed in the top right of the EB console.

That’s it! You can view my finished application here. I also have a repository with additional examples of simple Plotly Dash apps, for easy imitation, here.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store