Bug description

When using bring your own DB, the superset-init-db k8s main job breaks under this error:

pgrading DB schema... Loaded your LOCAL configuration at [/app/pythonpath/superset_config.py] 2025-09-17 12:41:33,296:ERROR:superset.app:Failed to create app Traceback (most recent call last): File "/app/.venv/lib/python3.10/site-packages/superset/app.py", line 40, in create_app app_initializer.init_app() [...] File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1685, in invoke super().invoke(ctx) File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) File "/app/.venv/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func return f(get_current_context(), *args, **kwargs) File "/app/.venv/lib/python3.10/site-packages/flask/cli.py", line 355, in decorator app = __ctx.ensure_object(ScriptInfo).load_app() File "/app/.venv/lib/python3.10/site-packages/flask/cli.py", line 309, in load_app app = locate_app(import_name, name) File "/app/.venv/lib/python3.10/site-packages/flask/cli.py", line 238, in locate_app return find_app_by_string(module, app_name) File "/app/.venv/lib/python3.10/site-packages/flask/cli.py", line 166, in find_app_by_string app = attr(*args, **kwargs) File "/app/.venv/lib/python3.10/site-packages/superset/app.py", line 40, in create_app app_initializer.init_app() File "/app/.venv/lib/python3.10/site-packages/superset/initialization/__init__.py", line 466, in init_app self.setup_db() File "/app/.venv/lib/python3.10/site-packages/superset/initialization/__init__.py", line 662, in setup_db pessimistic_connection_handling(db.engine) File "/app/.venv/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 998, in engine return self.get_engine() File "/app/.venv/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 1017, in get_engine return connector.get_engine() File "/app/.venv/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 594, in get_engine self._engine = rv = self._sa.create_engine(sa_url, options) File "/app/.venv/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 1027, in create_engine return sqlalchemy.create_engine(sa_url, **engine_opts) File "<string>", line 2, in create_engine File "/app/.venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned return fn(*args, **kwargs) File "/app/.venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 544, in create_engine dbapi = dialect_cls.dbapi(**dbapi_args) File "/app/.venv/lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 811, in dbapi import psycopg2 ModuleNotFoundError: No module named 'psycopg2'

Comment From: dosubot[bot]

Hi @thatguyatgithub! I'm Dosu and I’m helping the superset team.

This is a known issue: the default Superset Docker image used by the Helm chart does not include database drivers like psycopg2, which are required to connect to external PostgreSQL databases. You have a few options to resolve this:

  1. Add a bootstrapScript to your Helm values.yaml to install psycopg2-binary and its system dependencies at container startup. For Superset v5 and newer (which use uv as the Python package manager), use:

yaml bootstrapScript: | #!/bin/bash apt update && apt install -y gcc libpq-dev python3-dev pkg-config uv pip install psycopg2-binary Reference

For older versions, replace uv pip install with pip install.

  1. Use a custom Docker image that pre-installs psycopg2-binary and any other required drivers. This is recommended for production deployments. Example Dockerfile:

dockerfile FROM apache/superset:latest RUN pip install --no-cache-dir psycopg2-binary Reference

  1. Use the -dev tagged Superset image (e.g., apache/superset:latest-dev), which includes common database drivers by default. Reference

Make sure you also disable the internal PostgreSQL by setting postgresql.enabled: false in your values.yaml when using an external DB, and provide your DB connection details under supersetNode.connections (do not set SQLALCHEMY_DATABASE_URI directly) Reference.

This approach should resolve the ModuleNotFoundError: No module named 'psycopg2' in your Helm-based deployment.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

Comment From: rusackas

@villebro we keep seeing issues like this arise. Any idea how to resolve this more permanently? Tempted to bump these to Discussions when they arise, but clearly it's a recurring issue.