@echo OFF
cls
REM Description...
::
:: This is basically the same as the other version here:
::
:: https://pastebin.com/mbcK7zxh
::
:: I modified it to add JupyterLab kernels to each new virtual environment. But if you
:: don't use JupyterLab, then don't use this new version.
::
:: If you need to remove a virtual environment in the future, simply delete its folder as
:: usual, then run this from the commandline:
::
:: jupyter kernelspec uninstall venv_plotly
::
:: Just replace "venv_plotly" with the kernel name - always lowercase.
REM Create the new 'venv' folder.
set "PYTHON=%USERPROFILE%\Code\Python"
set /P "PROJECT=New project name: "
title [VENV] %PROJECT%
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
set "CREATED=TRUE"
REM Create a new Python file.
echo #!python3>"%PRDIR%\run.py"
call :NPP
) else (
echo That project already exists.
pause
call :NPP
)
REM Install some more libraries in the virtual environment.
if "%CREATED%" == "TRUE" (
pushd "%ENV%\Scripts"
call "activate.bat"
python pip.exe install wheel
python pip.exe install ipykernel || REM Installs the JupyterLab kernel.
python -m ipykernel install --user --name="venv_%PROJECT%" || REM Adds the kernel to JupyterLab.
call "deactivate.bat"
popd
)
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
0 B
|👍
/👎