J2897 icon

New Python environment (venv)

J2897 | PRO | 11/24/21 08:53:24 PM UTC (Edited) | 0 ⭐ | 1770 👁️ | Never ⏰ | []
Batch |

710 B

|

None

|

0 👍

/

0 👎

@echo OFF
cls
 
REM Create the new 'venv' folder.
set "PYTHON=%USERPROFILE%\Code\Python"
set /P "PROJECT=New project name: "
set "PRDIR=%PYTHON%\%PROJECT%"
set "ENV=%PRDIR%\venv"
if not exist "%ENV%" (
    mkdir "%ENV%"
    REM Create the virtual environment.
    echo Creating the virtual environment . . .
    python -m venv "%ENV%" --upgrade-deps 
    REM Create a new Python file.
    echo #!python3>"%PRDIR%\run.py"
    call :NPP
) else (
    echo That project already exists.
    pause
    call :NPP
)
 
REM Activate the virtual environment.
cd "%PRDIR%"
cmd /K "%ENV%\Scripts\activate.bat"
goto :EOF
 
REM Open the new Python file.
:NPP
start "" /D "%PRDIR%" "C:\Program Files\Notepad++\notepad++.exe" "%PRDIR%\run.py"
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎