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

Works:
`pip install -t $PYTHONPATH psycopg2-binary` (run as root)
This actually installs pkg to `/app/pythonpath` (see envvar)

pip installs packages to 
`/app/superset_home/.local/lib/python3.10/site-packages/` when run as 
`superset`, and to `/usr/local/lib/python3.10/site-packages` when run as `root`.
Nothing of this exists in `sys.path`:
```bash
(.venv) root@9c13caf9844e:/app# python -c 'import sys; print(sys.path)'
['', '/app/pythonpath', '/usr/local/lib/python310.zip', 
'/usr/local/lib/python3.10', '/usr/local/lib/python3.10/lib-dynload', 
'/app/.venv/lib/python3.10/site-packages']
```

Multistage build example:
```Dockerfile
FROM apache/superset:6.0.0 AS pg_pkg

USER root
RUN /bin/bash -c "source .venv/bin/activate; pip install -t $PYTHONPATH 
psycopg2-binary"

FROM apache/superset:6.0.0
COPY --from=pg_pkg /app/pythonpath /app/pythonpath
```

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

----
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