Advertisement
J2897

New Python environment (venv)

Sep 24th, 2021 (edited)
1,130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.71 KB | None | 0 0
  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. cmd /K "%ENV%\Scripts\activate.bat"
  26. goto :EOF
  27.  
  28. REM Open the new Python file.
  29. :NPP
  30. start "" /D "%PRDIR%" "C:\Program Files\Notepad++\notepad++.exe" "%PRDIR%\run.py"
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement