import pkg_resources from subprocess import call call("venv\Scripts\python.exe -m pip install --upgrade pip", shell=True) packages = [dist.project_name for dist in pkg_resources.working_set] call("venv\Scripts\python.exe -m pip install --upgrade " + ' '.join(packages), shell=True)
References
https://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip