GitHub user gatos-cc added a comment to the discussion: ModuleNotFoundError: No 
module named 'psycopg2' during k8 installation

Is there an update on this?  Thread is almost a year old, and the basic 
tutorial on the Superset website doesn't work.

First off Bitnami has put the upstream postgres/redis images behind a paywall, 
so have to figure out how to get those from another source and into a helm 
chart (for someone that has never used Helm before).  But now this issue.

Following the comments above, I have:
```
bootstrapScript: |
  #!/bin/bash
  
  # Install system-level dependencies
  apt-get update && apt-get install -y \
    python3-dev \
    default-libmysqlclient-dev \
    build-essential \
    pkg-config

  # Install required Python packages
  pip install \
    authlib \
    psycopg2-binary \
    mysqlclient \

  # Create bootstrap file if it doesn't exist
  if [ ! -f ~/bootstrap ]; then
    echo "Running Superset with uid {{ .Values.runAsUser }}" > ~/bootstrap
  fi
```

Logs from the init-db pod show it was installed:
```
Successfully installed authlib-1.6.5 cffi-2.0.0 cryptography-46.0.3 
mysqlclient-2.2.7 psycopg2-binary-2.9.11 pycparser-2.23 typing-extensions-4.15.0
```

but then it still errors out anyway:
```
Traceback (most recent call last):
  File "/app/.venv/bin/superset", line 10, in <module>
    sys.exit(superset())
  File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1157, in 
__call__
    return self.main(*args, **kwargs)
  File "/app/.venv/lib/python3.10/site-packages/click/core.py", line 1078, in 
main
    rv = self.invoke(ctx)
  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'
```

If I had to guess, the venv is using a different python than whatever apt is 
installing the library into.  So following the next set of comments, using uv:
```
bootstrapScript: |
  #!/bin/bash
  
  # Install system-level dependencies
  apt-get update && apt-get install -y

  uv pip install \
    authlib \
    psycopg2-binary \
    mysqlclient \  

  # Create bootstrap file if it doesn't exist
  if [ ! -f ~/bootstrap ]; then
    echo "Running Superset with uid {{ .Values.runAsUser }}" > ~/bootstrap
  fi
```

still errors:
```
error: Failed to parse: ` `
  Caused by: Empty field is not allowed for PEP508
 
^
Upgrading DB schema...
Loaded your LOCAL configuration at [/app/pythonpath/superset_config.py]
2025-10-24 02:35:22,810:ERROR:superset.app:Failed to create app
Traceback (most recent call last):
...
  File 
"/app/.venv/lib/python3.10/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py",
 line 811, in dbapi
    import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
```

This is brutal for someone just trying to figure out what Superset is and 
whether or not it could be useful.


GitHub link: 
https://github.com/apache/superset/discussions/31431#discussioncomment-14768151

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to