[PR #13321] [CLOSED] fix: ensure uvicorn uses correct Python environment (venv/pyenv) by invoking via python #23154

Closed
opened 2026-04-20 04:40:11 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/13321
Author: @dh4340
Created: 4/29/2025
Status: Closed

Base: mainHead: patch-1


📝 Commits (1)

  • 8f31b6d Fix: Use dynamic Python command to run uvicorn and support pyenv setups.

📊 Changes

1 file changed (+3 additions, -1 deletions)

View changed files

📝 backend/start.sh (+3 -1)

📄 Description

Description:

This PR updates the application startup command to invoke uvicorn via the appropriate Python interpreter instead of calling uvicorn directly. This ensures the correct virtual environment (venv) or pyenv-managed Python version is used, avoiding accidental fallback to the system Python.

Changes:

  • Replaced:
    exec uvicorn open_webui.main:app ...
    
    with:
    PYTHON_CMD=$(command -v python3 || command -v python)
    exec "$PYTHON_CMD" -m uvicorn open_webui.main:app ...
    

Motivation:

  • Directly running uvicorn may use the system Python, ignoring the active virtual environment or pyenv configuration.
  • This causes dependency mismatches or unexpected behavior in customized Python setups.
  • Running uvicorn via python -m ensures it is invoked using the correct Python context.

Impact:

  • Improves reliability across different environments (system Python, venv, pyenv).
  • No functional changes to the app logic; only affects how it's launched.

Testing:

  • Validated on:
    • pyenv environments
    • Virtual environments (venv)
    • Bare systems with only python3 or python
  • Confirmed that the correct interpreter and dependencies are used in all cases.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/13321 **Author:** [@dh4340](https://github.com/dh4340) **Created:** 4/29/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`8f31b6d`](https://github.com/open-webui/open-webui/commit/8f31b6d74af2e144d471f8080bd3b229687e4bb0) Fix: Use dynamic Python command to run uvicorn and support pyenv setups. ### 📊 Changes **1 file changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/start.sh` (+3 -1) </details> ### 📄 Description ### Description: This PR updates the application startup command to invoke `uvicorn` via the appropriate Python interpreter instead of calling `uvicorn` directly. This ensures the correct virtual environment (`venv`) or `pyenv`-managed Python version is used, avoiding accidental fallback to the system Python. #### Changes: - Replaced: ```bash exec uvicorn open_webui.main:app ... ``` with: ```bash PYTHON_CMD=$(command -v python3 || command -v python) exec "$PYTHON_CMD" -m uvicorn open_webui.main:app ... ``` #### Motivation: - Directly running `uvicorn` may use the system Python, ignoring the active virtual environment or `pyenv` configuration. - This causes dependency mismatches or unexpected behavior in customized Python setups. - Running `uvicorn` via `python -m` ensures it is invoked using the correct Python context. #### Impact: - Improves reliability across different environments (system Python, `venv`, `pyenv`). - No functional changes to the app logic; only affects how it's launched. #### Testing: - Validated on: - `pyenv` environments - Virtual environments (`venv`) - Bare systems with only `python3` or `python` - Confirmed that the correct interpreter and dependencies are used in all cases. --- --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 04:40:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#23154