J2897

Python Module Upgrader - Admin

Sep 25th, 2021 (edited)
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.82 KB | None | 0 0
  1. @echo OFF
  2. title Python Module Upgrader (Admin)
  3.  
  4. :: This will upgrade all the modules in the GLOBAL environment.
  5. ::
  6. :: You can run this after installing the Chocolatey version of Python, or before
  7. :: setting up a new Python virtual environment with 'venv'.
  8.  
  9. REM Do OPENFILES to check for administrative privileges.
  10. openfiles >nul 2>&1
  11. if errorlevel 1 (
  12.     color cf
  13.     echo Right-click on this file and select "Run as administrator".
  14.     pause
  15.     color
  16.     exit /b 1
  17. )
  18.  
  19. REM Upgrade PIP.
  20. python -m pip install --upgrade pip
  21.  
  22. REM Upgrades all of Python's PIP packages, presuming PIP is installed.
  23. for /F "delims==" %%A in ('python -m pip list --format freeze') do (
  24.     REM Package name to skip and exclude from upgrading.
  25.     if not "%%A" == "pip" (
  26.         REM Upgrade package.
  27.         python -m pip install --upgrade %%A
  28.     )
  29. )
  30. echo.
  31. pause
Add Comment
Please, Sign In to add comment