Skip to content

Batch - Python Virtual Environment

Source: Windows batch file for quick virtualenv creation (github.com)

@echo off

for /f "tokens=*" %%C in ( 'python3.9 -c "import os, re; print(re.search(r'[^\\]+$', os.getcwd(), re.M).group(0))"' ) do (
    set DIRNAME=%%C
)

if [%2]==[] (
    python%1 -m virtualenv env --prompt="(%DIRNAME%) "    
) else (
    python%1 -m virtualenv env --prompt="(%2) "
)

Backlinks:

list from [[Batch - Python Virtual Environment]] AND -"Changelog"