J2897

New Python environment (venv)

Sep 24th, 2021 (edited)
696
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo OFF
  2. cls
  3.  
  4. REM Create the new 'venv' folder.
  5. set "PYTHON=%USERPROFILE%\Code\Python"
  6. set /P "PROJECT=New project name: "
  7. set "PRDIR=%PYTHON%\%PROJECT%"
  8. set "ENV=%PRDIR%\venv"
  9. if not exist "%ENV%" (
  10.     mkdir "%ENV%"
  11.     REM Create the virtual environment.
  12.     echo Creating the virtual environment . . .
  13.     python -m venv "%ENV%" --upgrade-deps
  14.     REM Create a new Python file.
  15.     echo #!python3>"%PRDIR%\run.py"
  16.     call :NPP
  17. ) else (
  18.     echo That project already exists.
  19.     pause
  20.     call :NPP
  21. )
  22.  
  23. REM Activate the virtual environment.
  24. cd "%PRDIR%"
  25. "%ENV%\Scripts\activate.bat"
  26. REM This line will not be executed.
  27.  
  28. REM Open the new Python file.
  29. :NPP
  30. start "" /D "%PRDIR%" "C:\Program Files\Notepad++\notepad++.exe" "%PRDIR%\run.py"
  31.  
RAW Paste Data