From d29250ab9a5b09fa57ddfd61caa97fadeaba2a4d Mon Sep 17 00:00:00 2001 From: Nanaloveyuki Date: Sun, 27 Jul 2025 14:55:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20=20=E8=99=9A=E6=8B=9F=E7=8E=AF?= =?UTF-8?q?=E5=A2=83`windows`=E7=AB=AF=E8=87=AA=E5=8A=A8=E5=8C=96=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init_venv.bat | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 init_venv.bat diff --git a/init_venv.bat b/init_venv.bat new file mode 100644 index 0000000..3198509 --- /dev/null +++ b/init_venv.bat @@ -0,0 +1,30 @@ +echo Running init for Python Virtual Environment... +:: Removed unnecessary timeout +:: timeout /t 3 +:: Check if either venv or .venv exists +if exist "venv" ( + set "VENV_DIR=venv" +) else if exist ".venv" ( + set "VENV_DIR=.venv" +) + +:: If virtual environment exists, activate it +if defined VENV_DIR ( + echo Python virtual environment already exists in %VENV_DIR%. + echo Activating virtual environment... + call "%VENV_DIR%\Scripts\activate.bat" + echo Virtual environment activated. +) else ( + :: Create virtual environment with venv + echo Creating Python virtual environment... + call python -m venv venv + if %errorlevel% neq 0 ( + echo Error: Failed to create virtual environment. + exit /b %errorlevel% + ) + set "VENV_DIR=venv" + echo Virtual environment created. + echo Activating virtual environment... + call "%VENV_DIR%\Scripts\activate.bat" + echo Virtual environment activated. +)