fix: use venv instead of pip install --user
- Remove automatic Python installation - user must have Python 3.11+ in image - Use virtual environment (~/.open-webui-venv) to avoid externally-managed-environment error - Add set -e to fail script on errors - Update README with installation instructions
This commit is contained in:
parent
25636524d3
commit
6e94ecc165
@ -14,15 +14,16 @@ This module installs and runs Open WebUI using Python and pip within your Coder
|
|||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- **Python 3.11 or higher** (automatically installed from [deadsnakes PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa) if not present)
|
- **Python 3.11 or higher** must be installed in your image (with `venv` module)
|
||||||
- `pip` package manager
|
|
||||||
- `sudo` access (for automatic Python installation if needed)
|
|
||||||
- Port 7800 (default) or your custom port must be available
|
- Port 7800 (default) or your custom port must be available
|
||||||
|
|
||||||
**Note:** If Python 3.11+ is not found, the module will automatically:
|
For Ubuntu/Debian, you can install Python 3.11 from [deadsnakes PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa):
|
||||||
1. Add the deadsnakes PPA repository
|
|
||||||
2. Install Python 3.11 with venv and dev packages
|
```shell
|
||||||
3. Install pip if not available
|
sudo add-apt-repository -y ppa:deadsnakes/ppa
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y python3.11 python3.11-venv
|
||||||
|
```
|
||||||
|
|
||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
set -e
|
||||||
|
|
||||||
# shellcheck disable=SC2059
|
# shellcheck disable=SC2059
|
||||||
printf '\033[0;1mInstalling Open WebUI...\n\n'
|
printf '\033[0;1mInstalling Open WebUI...\n\n'
|
||||||
@ -29,40 +30,30 @@ for cmd in python3.13 python3.12 python3.11 python3 python; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$PYTHON_CMD" ]; then
|
if [ -z "$PYTHON_CMD" ]; then
|
||||||
echo "❌ Python 3.11 or higher is not installed"
|
echo "❌ Python 3.11 or higher is required but not found."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Installing Python 3.11 from deadsnakes PPA..."
|
echo "Please install Python 3.11+ in your image. For example on Ubuntu/Debian:"
|
||||||
|
echo " sudo add-apt-repository -y ppa:deadsnakes/ppa"
|
||||||
# Check if we have sudo access
|
echo " sudo apt-get update"
|
||||||
if ! command -v sudo > /dev/null 2>&1; then
|
echo " sudo apt-get install -y python3.11 python3.11-venv"
|
||||||
echo "❌ sudo is not available. Please install Python 3.11+ manually"
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Python 3.11
|
# Set up virtual environment
|
||||||
echo "📦 Adding deadsnakes PPA..."
|
VENV_DIR="$HOME/.open-webui-venv"
|
||||||
sudo apt-get update -qq
|
if [ ! -d "$VENV_DIR" ]; then
|
||||||
sudo apt-get install -y software-properties-common
|
echo "📦 Creating virtual environment..."
|
||||||
sudo add-apt-repository -y ppa:deadsnakes/ppa
|
"$PYTHON_CMD" -m venv "$VENV_DIR"
|
||||||
sudo apt-get update -qq
|
|
||||||
|
|
||||||
echo "📦 Installing Python 3.11..."
|
|
||||||
sudo apt-get install -y python3.11 python3.11-venv python3.11-dev
|
|
||||||
|
|
||||||
PYTHON_CMD="python3.11"
|
|
||||||
echo "✅ Python 3.11 installed successfully"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if pip is available
|
# Activate virtual environment
|
||||||
if ! "$PYTHON_CMD" -m pip --version > /dev/null 2>&1; then
|
# shellcheck disable=SC1091
|
||||||
echo "📦 Installing pip..."
|
. "$VENV_DIR/bin/activate"
|
||||||
curl -sS https://bootstrap.pypa.io/get-pip.py | "$PYTHON_CMD"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if open-webui is already installed
|
# Check if open-webui is already installed
|
||||||
if ! "$PYTHON_CMD" -m pip show open-webui > /dev/null 2>&1; then
|
if ! pip show open-webui > /dev/null 2>&1; then
|
||||||
echo "📦 Installing Open WebUI..."
|
echo "📦 Installing Open WebUI..."
|
||||||
"$PYTHON_CMD" -m pip install --user open-webui
|
pip install open-webui
|
||||||
echo "🥳 Open WebUI has been installed"
|
echo "🥳 Open WebUI has been installed"
|
||||||
else
|
else
|
||||||
echo "✅ Open WebUI is already installed"
|
echo "✅ Open WebUI is already installed"
|
||||||
@ -78,7 +69,7 @@ echo "👷 Starting Open WebUI in background..."
|
|||||||
echo "Check logs at $LOG_PATH"
|
echo "Check logs at $LOG_PATH"
|
||||||
|
|
||||||
# Start Open WebUI
|
# Start Open WebUI
|
||||||
"$PYTHON_CMD" -m open_webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 &
|
open-webui serve --host 0.0.0.0 --port "$PORT" > "$LOG_PATH" 2>&1 &
|
||||||
|
|
||||||
# Wait a bit for the server to start
|
# Wait a bit for the server to start
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user