fix(run.sh): add check for python3-venv and provide instructions

This commit is contained in:
xucheng 2025-10-30 15:16:45 +08:00
parent 2f7cd70d36
commit 194a4d4377

View File

@ -2,6 +2,24 @@
# Exit immediately if a command exits with a non-zero status. # Exit immediately if a command exits with a non-zero status.
set -e set -e
# --- Prerequisite check for python3-venv ---
echo "Checking for Python venv module..."
if ! python3 -c 'import venv' &> /dev/null; then
echo "Python 'venv' module is missing. It's required to create a virtual environment for the backend."
# Attempt to provide specific installation instructions
if command -v apt &> /dev/null; then
PY_VERSION_SHORT=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
echo "It seems you are on a Debian/Ubuntu-based system. Please install the venv module by running:"
echo "sudo apt update && sudo apt install python${PY_VERSION_SHORT}-venv"
else
echo "Please install the Python 'venv' module for your system."
fi
exit 1
fi
echo "Python venv module found."
# --- Backend Setup --- # --- Backend Setup ---
echo "Setting up backend..." echo "Setting up backend..."
cd backend cd backend