dosubot[bot] commented on issue #37560: URL: https://github.com/apache/superset/issues/37560#issuecomment-3822676275
<!-- Answer --> This happens because in Superset 5.x+ Docker images, Python packages must be installed with `uv pip install` (not just `pip install`) to be available in the runtime environment. If you use `pip install`, pyodbc ends up outside the virtual environment Superset actually uses, causing the `ModuleNotFoundError` you’re seeing. To fix this, update your Dockerfile to install pyodbc like this (as root, before switching back to the `superset` user): ```dockerfile FROM apache/superset:latest USER root RUN uv pip install --no-cache-dir pyodbc USER superset ``` Then rebuild your Docker image with `docker compose build --force-rm` (or `docker build --no-cache ...`), and restart your container. After that, `python -c "import pyodbc; print(pyodbc.drivers())"` inside the container should work as expected. If you still have issues, please share your Dockerfile snippet and the output of `uv pip list` or `pip freeze` inside the container so I can help troubleshoot further. References: - [Superset 5.x Dockerfile and package installation](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/Dockerfile#L117-L226) - [Why 'uv pip install' is required for drivers like pyodbc](https://github.com/apache/superset/issues/34557) <!-- 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/1ab75f12-a5ac-41e0-af92-d67295de3474?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1ab75f12-a5ac-41e0-af92-d67295de3474?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1ab75f12-a5ac-41e0-af92-d67295de3474?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1ab75f12-a5ac-41e0-af92-d67295de3474?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1ab75f12-a5ac-41e0-af92-d67295de3474?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1ab75f12-a5ac-41e0-af92-d67295de3474?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1ab75f12-a5ac-41e0-af92-d67295de3474?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=This%20happens%20because%20in%20Superset%205.x%2B%20Docker%20images%2C%20Python%20packages%20must%20be%20installed%20with%20%60uv%20pip%20install%60%20%28not%20just%20%60pip%20install%60%29%20to%20be%20available%20in%20the%20runtime%20environment.%20If%20you%20use%20%60pip%20install%60%2C%20pyodbc%20ends%20up%20outside%20the%20virtual%20environment%20Superset%20actually%20uses%2C%20causing%20the%20%60ModuleNotFoundError%60%20you%E2%80%99re%20seeing.%0A%0ATo%20fix%20this%2C%20update%20your%20Dockerfile%20to%20install%20pyodbc%20like%20this%20%28as%20root%2C%20before%20switching%20back%20to%20the%20%60superset%60%20user%29%3A%0A%0A%60%60%60dockerfile%0AFROM%20apache/superset%3Alatest%0AUSER%20root%0ARUN%20uv%20pip%20install%20--no-cache-dir%20pyodbc% 0AUSER%20superset%0A%60%60%60%0A%0AThen%20rebuild%20your%20Docker%20image%20with%20%60docker%20compose%20build%20--force-rm%60%20%28or%20%60docker%20build%20--no-cache%20...%60%29%2C%20and%20restart%20your%20container.%20After%20that%2C%20%60python%20-c%20%22import%20pyodbc%3B%20print%28pyodbc.drivers%28%29%29%22%60%20inside%20the%20container%20should%20work%20as%20expected.%0A%0AIf%20you%20still%20have%20issues%2C%20please%20share%20your%20Dockerfile%20snippet%20and%20the%20output%20of%20%60uv%20pip%20list%60%20or%20%60pip%20freeze%60%20inside%20the%20container%20so%20I%20can%20help%20troubleshoot%20further.%0A%0AReferences%3A%20%20%0A-%20%5BSuperset%205.x%20Dockerfile%20and%20package%20installation%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/Dockerfile%23L117-L226%29%20%20%0A-%20%5BWhy%20%27uv%20pip%20install%27%20is%20required%20for%20drivers%20like%20pyodbc%5D%28https%3A//github.com/apache/superset/issues/34557%29) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37560) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
