Advertisement
J2897

Python Module Upgrader - User

Sep 25th, 2021 (edited)
1,395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.11 KB | None | 0 0
  1. @echo OFF
  2. title Python Module Upgrader (User)
  3.  
  4. :: This will upgrade all the modules in the USER environment only, leaving
  5. :: the GLOBAL environment untouched - to avoid breaking Python.
  6. ::
  7. :: You can run this after installing the Chocolatey version of Python, or before
  8. :: setting up a new Python virtual environment with 'venv'.
  9. ::
  10. :: If you've just installed Python via Chocolatey, you could bring the GLOBAL
  11. :: environment up to date before you begin your first project:
  12. :: python -m pip install --upgrade pip setuptools
  13.  
  14. REM Do OPENFILES to check for administrative privileges.
  15. openfiles >nul 2>&1
  16. if not errorlevel 1 (
  17.     echo You can run this as a regular user.
  18.     echo Simply double-click on the file.  
  19.     pause
  20.     exit /b 1
  21. )
  22.  
  23. REM Upgrade PIP.
  24. ::python -m pip install --upgrade pip --user
  25.  
  26. REM Upgrades all of Python's PIP packages, presuming PIP is installed.
  27. for /F "delims==" %%A in ('python -m pip list --user --format freeze') do (
  28.     REM Package name to skip and exclude from upgrading.
  29.     if not "%%A" == "pip" (
  30.         REM Upgrade package.
  31.         python -m pip install --upgrade %%A --user
  32.     )
  33. )
  34. echo.
  35. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement