GitHub user dosubot[bot] added a comment to the discussion: 
ModuleNotFoundError: No module named 'authlib' when implementing Google OAuth 
with Apache Superset Docker

<!-- Answer -->
The root cause is that recreating `/app/.venv` in your Dockerfile (with 
`python3 -m venv /app/.venv`) overwrites the pre-configured virtual environment 
from the Superset base image, removing all required packages and breaking 
Superset’s dependencies. This leads to persistent `ModuleNotFoundError` errors 
for packages like `authlib` and others 
[reference](https://github.com/apache/superset/issues/34557) 
[reference](https://github.com/apache/superset/issues/32186).

**Solution:**  
Do not recreate `/app/.venv`. Instead, install extra Python packages directly 
into the existing environment. Here’s the correct pattern:

```dockerfile
FROM apache/superset:latest

USER root
RUN apt update && apt install -y \
    python3-dev \
    default-libmysqlclient-dev \
    build-essential \
    pkg-config \
    && rm -rf /var/lib/apt/lists/*

RUN uv pip install --no-cache-dir mysqlclient pymysql gunicorn authlib==1.2.0

COPY superset_config.py /app/superset_home/superset_config.py
RUN chown superset:superset /app/superset_home/superset_config.py

USER superset

CMD ["gunicorn", "-w", "2", "--threads", "8", "-b", "0.0.0.0:8088", 
"superset.app:create_app()"]
```

If `uv` isn’t available, use `/app/.venv/bin/pip install <package>` instead. 
You can verify the install during build with `/app/.venv/bin/python -c "import 
authlib"` [reference](https://github.com/apache/superset/issues/34185).

For maintainability, you can add dependencies to a `requirements-local.txt` and 
install with `uv pip install -r requirements-local.txt` 
[reference](https://github.com/apache/superset/issues/34557).

Let me know if you still see the error after removing the `python3 -m venv 
/app/.venv` line!


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/4ec45125-8b0e-4a07-9ee9-201efec58171?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/4ec45125-8b0e-4a07-9ee9-201efec58171?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/4ec45125-8b0e-4a07-9ee9-201efec58171?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/4ec45125-8b0e-4a07-9ee9-201efec58171?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/4ec45125-8b0e-4a07-9ee9-201efec58171?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/4ec45125-8b0e-4a07-9ee9-201efec58171?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/4ec45125-8b0e-4a07-9ee9-201efec58171?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/35183)

GitHub link: 
https://github.com/apache/superset/discussions/35183#discussioncomment-14439167

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