Skip to main content

PiPy Installation

Superset 6.x ready

This walkthrough installs Apache Superset 6.x from PyPI (apache_superset) on Python 3.11.

Tutorial to follow along

A new tutorial video is coming soon. Until it is published, use the walkthrough below: it still matches the general flow of this guide.

Set up environment

This guide targets Python 3.11 end-to-end. Use python3.11 (not python3) so the venv matches 3.11 even when the system default is newer (for example 3.12).

On many Ubuntu releases (notably when the default Python is 3.12), python3.11 is not in the default apt repositories. If apt-get reports Unable to locate package python3.11, use Ubuntu steps below (deadsnakes PPA) or install 3.11 another way (e.g. pyenv) before continuing.

  • Update Ubuntu/Debian
sudo apt update -y && sudo apt upgrade -y
  • Install dependencies (includes Python 3.11 interpreter, headers, and venv support)
sudo apt-get install -y build-essential libssl-dev libffi-dev libsasl2-dev libldap2-dev default-libmysqlclient-dev python3.11 python3.11-dev python3.11-venv

Ubuntu: Unable to locate package python3.11

Add the deadsnakes PPA, refresh apt, then run the same dependency install command again:

sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update
sudo apt-get install -y build-essential libssl-dev libffi-dev libsasl2-dev libldap2-dev default-libmysqlclient-dev python3.11 python3.11-dev python3.11-venv

Debian

Enable contrib and non-free if your mirror requires them for some drivers, then try sudo apt update and the same apt-get install line. If 3.11 is still missing, install it from your release’s backports or use pyenv to build 3.11.

  • Confirm Python 3.11 is on your PATH before continuing
python3.11 --version
  • Create app directory for superset and dependencies
sudo mkdir /app
sudo chown "$USER" /app
cd /app
  • Create a Python 3.11 virtual environment
mkdir superset
cd superset
python3.11 -m venv superset_env
source superset_env/bin/activate
python --version
python -m pip install --upgrade pip
  • Install required Python packages (venv active; one line each for clarity)
python -m pip install pillow
python -m pip install gunicorn
python -m pip install gevent
python -m pip install apache_superset

The apache_superset package on PyPI is Superset itself.

  • Create superset config file and set environment variable
touch superset_config.py
export SUPERSET_CONFIG_PATH=/app/superset/superset_config.py

  • Edit and paste following code in it
# Superset specific config
ROW_LIMIT = 5000

# Flask App Builder configuration
# Your App secret key will be used for securely signing the session cookie
# and encrypting sensitive information on the database
# Make sure you are changing this key for your deployment with a strong key.
# Alternatively you can set it with `SUPERSET_SECRET_KEY` environment variable.
# You MUST set this for production environments or the server will refuse
# to start and you will see an error in the logs accordingly.
SECRET_KEY = 'YOUR_OWN_RANDOM_GENERATED_SECRET_KEY'

# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
# The check_same_thread=false property ensures the sqlite client does not attempt
# to enforce single-threaded access, which may be problematic in some edge cases
SQLALCHEMY_DATABASE_URI = 'sqlite:////app/superset/superset.db?check_same_thread=false'

TALISMAN_ENABLED = False
WTF_CSRF_ENABLED = False

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''

Please replace YOUR_OWN_RANDOM_GENERATED_SECRET_KEY in above file with the code returned by following command

openssl rand -base64 42
  • Once done, initialize the database (from /app/superset with the 3.11 venv activated: source superset_env/bin/activate)
export FLASK_APP=superset

superset db upgrade
superset fab create-admin
# superset load_examples
superset init

Running superset for testing

  • Now Our environment is ready lets try running it.. To run superset I have created a sh script that you can run in order to run the server. To create create script using following command.
nano run_superset.sh

and paste following code in it.

#!/bin/bash
export SUPERSET_CONFIG_PATH=/app/superset/superset_config.py
source /app/superset/superset_env/bin/activate
gunicorn \
-w 10 \
-k gevent \
--timeout 120 \
-b 0.0.0.0:8088 \
--limit-request-line 0 \
--limit-request-field_size 0 \
"superset.app:create_app()"
  • In order to run it we need to grant it run permission. To do that lets run following command.
chmod +x run_superset.sh
  • Lets run and test if it works?
sh run_superset.sh
  • check if you are able to login using admin creds on server-ip-address:8088. If everything is working fine then we can go ahead and create service that will start automatically as soon as server starts or in case it reboots.

Creating service for Superset

Lets create service called superset using following command

sudo nano /etc/systemd/system/superset.service

paste following code in it

[Unit]
Description = Apache Superset Webserver Daemon
After = network.target

[Service]
PIDFile = /app/superset/superset-webserver.PIDFile
Environment=SUPERSET_HOME=/app/superset
Environment=PYTHONPATH=/app/superset
WorkingDirectory = /app/superset
ExecStart = /app/superset/run_superset.sh
ExecStop = /bin/kill -s TERM $MAINPID


[Install]
WantedBy=multi-user.target

once copied run following command to enable and start service

systemctl daemon-reload
sudo systemctl enable superset.service
sudo systemctl start superset.service

YEY! Your production Server is Up and running you can test it by restarting the server...

If you have any issues you can contact me on [email protected] .

"Buy Me A Coffee"