Skip to content
Switch branches/tags

Dash Earthquakes

License: MIT Build Status Code style: black

A Plotly Dash application showing earthquake data from the US Geological Survey.

The GeoJSON summary feed from the USGS website is updated every 15 minutes and it refers to the 4.5+ magnitude earthquakes occurred in the past month.

A GIF file showing a short demo on how to use the Dash Earthquakes dashboard

App on CapRover.

Built with:

API keys

This project requires to get some API keys from external services.


This project uses pyenv and pyenv-virtualenv to manage the Python virtual environment, and poetry to manage the project dependencies.

If you don't already have it, install python 3.8.5.

pyenv install 3.8.5

Create a virtual environment and activate it.

pyenv virtualenv 3.8.5 dash_earthquakes
pyenv activate dash_earthquakes

Remember to activate the virtual environment every time you work on this project.

Install all the dependencies from the poetry.lock file.

poetry install


This project uses the task runner Poe the Poet to run poetry scripts.

Non-dockerized app

Run the app locally using a development server (Dash uses a Flask development server):

poetry run poe dev

# or, in alternative

Run the app locally using a production server (gunicorn):

poetry run poe prod

Run all tests with pytest:

poetry run poe test

Format all code with black:

poetry run poe format

Dockerized app

Build the Docker image and give it a name and a version tag:

docker build -t dash-earthquakes:v0.1.0 .

Run the Docker container:

docker run --env-file .env -p 5001:5000 dash-earthquakes:v0.1.0

Deploy the dockerized app on CapRover (running on my DigitalOcean Droplet):



If you are on Ubuntu you might get ModuleNotFoundError: No module named '_bz2' and/or UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError. These errors are caused by pandas when it tries to import these compression libraries. If you get these errors you need to install the libbz2-dev package and the liblzma-dev package, then re-compile your python interpreter.

Here is how you can do it:

# deactivate and remove the virtual environment
pyenv deactivate
pyenv virtualenv-delete dash_earthquakes

# remove the "broken" python interpreter
pyenv uninstall 3.8.5

# install the compression libreries
sudo apt-get install libbz2-dev liblzma-dev

# download and compile the python interpreter
pyenv install 3.8.5

# re-create the virtual environment and activate it
pyenv virtualenv 3.8.5 dash_earthquakes
pyenv activate dash_earthquakes

# re-install all the dependencies
poetry install


A Plotly Dash application showing earthquake data from the USGS website