venv fix
This commit is contained in:
21
install.sh
21
install.sh
@@ -24,8 +24,12 @@ echo "Installing crypto-trader to $INSTALL_DIR ..."
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
|
||||
# ── 2. Copy project files ─────────────────────────────────────────────────
|
||||
rsync -a --exclude='.git' --exclude='venv' --exclude='__pycache__' \
|
||||
"$SCRIPT_DIR/" "$INSTALL_DIR/"
|
||||
# Skip if already running from the install directory
|
||||
if [ "$SCRIPT_DIR" != "$INSTALL_DIR" ]; then
|
||||
for item in *.py *.txt *.sh *.md .env.example systemd; do
|
||||
[ -e "$SCRIPT_DIR/$item" ] && cp -r "$SCRIPT_DIR/$item" "$INSTALL_DIR/"
|
||||
done
|
||||
fi
|
||||
|
||||
# ── 3. Create dedicated system user ──────────────────────────────────────
|
||||
if ! id -u "$SERVICE_USER" &>/dev/null; then
|
||||
@@ -45,13 +49,16 @@ if [ ! -f "$INSTALL_DIR/.env" ]; then
|
||||
fi
|
||||
|
||||
# ── 5. Python virtual environment ─────────────────────────────────────────
|
||||
if ! command -v python3 &>/dev/null; then
|
||||
echo "Installing python3-venv ..."
|
||||
apt-get install -y python3-venv python3-pip
|
||||
fi
|
||||
# python3 is pre-installed on Ubuntu but python3-venv is a separate package
|
||||
# that is frequently absent — install it unconditionally (apt is idempotent)
|
||||
echo "Ensuring python3-venv and pip are available..."
|
||||
apt-get install -y python3-venv python3-pip
|
||||
|
||||
if [ ! -d "$INSTALL_DIR/venv" ]; then
|
||||
python3 -m venv "$INSTALL_DIR/venv"
|
||||
python3 -m venv "$INSTALL_DIR/venv" || {
|
||||
echo "ERROR: 'python3 -m venv' failed. Try: apt-get install python3-venv"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
"$INSTALL_DIR/venv/bin/pip" install --upgrade pip -q
|
||||
"$INSTALL_DIR/venv/bin/pip" install -r "$INSTALL_DIR/requirements.txt" -q
|
||||
|
||||
Reference in New Issue
Block a user