Python Migration & Cleanup Kit for Windows
Upgrading Python on Windows doesn’t have to mean starting from scratch.
This post walks through a safe side-by-side upgrade, a full cleanup option, and provides a downloadable PowerShell kit you can drop into your toolbox.
Download the kit here:
Why use a migration script instead of in-place upgrade?
Windows installs of Python aren’t designed for true in-place upgrades. Different versions can break binary packages, scripts are tied to specific interpreters, and some apps bundle their own Python that you shouldn’t touch.
The safer pattern is:
- Install the new Python version side-by-side.
- Reinstall your packages into the new interpreter.
- Move or recreate any helper scripts / entry points you rely on.
- Update PATH and file associations.
- Uninstall the old version once everything checks out.
The migration kit automates most of steps 2–3 and gives you a repeatable process for future upgrades.
What’s in the Python Migration & Cleanup Kit?
The ZIP contains these files:
migrate-python.ps1– one-stop helper that:- Exports packages from the old Python
- Installs them into the new Python
- Optionally copies your custom
.py/.cmdscripts from the oldScriptsfolder
-
export-requirements.ps1– exports a list of packages from your old Python into arequirements.txt-style file. -
install-requirements.ps1– installs packages from a requirements-style text file into the new Python. -
copy-custom-scripts.ps1– copies your own helper scripts from the oldScriptsfolder to the new one. Remove-All-Python.ps1– aggressive cleanup script that:- Optionally runs uninstallers for python.org installs
- Deletes common Python directories
- Backs up and cleans PATH
- Optionally removes Microsoft Store Python and the Python Launcher (
py.exe)
README.txt– usage overview and sample commands.
All scripts are written for Windows PowerShell and assume standard python.org installs (e.g., C:\\Users\\<you>\\AppData\\Local\\Programs\\Python\\Python311\\python.exe).
Option A: Migrate to a new Python version
- Install the new Python version from python.org and note both paths, e.g.:
- Old:
C:\\Users\\<you>\\AppData\\Local\\Programs\\Python\\Python311\\python.exe - New:
C:\\Users\\<you>\\AppData\\Local\\Programs\\Python\\Python313\\python.exe
- Old:
-
Open PowerShell in the folder where you extracted the ZIP.
- Allow script execution for this session only:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
- Run the migration helper:
.\migrate-python.ps1 `
-OldPython "C:\\Users\\<you>\\AppData\\Local\\Programs\\Python\\Python311\\python.exe" `
-NewPython "C:\\\Users\\<you>\\AppData\\Local\\Programs\\Python\\Python313\\python.exe" `
-CopyCustomScripts
This will:
- Export your packages from the old Python
- Upgrade
pipon the new Python - Reinstall the exported packages into the new Python
- Copy your
.pyand.cmdhelper scripts from the oldScriptsdirectory into the new one (if-CopyCustomScriptsis used)
Option B: Nuke Python and start clean
If your Python installs are tangled beyond patience, or you explicitly want a clean slate, use Remove-All-Python.ps1.
⚠ Warning: This can break applications that bundle or rely on a specific Python.
Make a backup or restore point first.
Run it from an elevated PowerShell (Run as Administrator):
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.\Remove-All-Python.ps1 `
-RunUninstallers `
-RemoveStorePython `
-RemovePyLauncher
What it does:
- Searches for python.org uninstallers and runs them (with
-RunUninstallers) - Removes common Python directories, including:
%LOCALAPPDATA%\\Programs\\Python%APPDATA%\\Python- Common
Program Files\\Python*locations
- Backs up your user and machine PATH to text files on your Desktop
- Removes Python-related PATH segments
- Optionally removes:
- Microsoft Store Python (
-RemoveStorePython) - Python Launcher (
py.exe) (-RemovePyLauncher)
- Microsoft Store Python (
After it finishes:
- Reboot.
- Install a fresh Python from python.org.
- Rebuild environments or use migration tools again to repopulate packages.
Verifying the new installation
After using the migration path or reinstalling after a wipe:
- Check which Python you’re getting on the command line:
where python
python --version
where py
py -0p
-
Fix your PATH if needed so that only the new Python’s
python.exeandScriptsdirectory are referenced. -
Open a project and run your usual commands (e.g.,
python -m pip list,pytest) to confirm everything behaves as expected.
Where to put the ZIP in your Jekyll site
For a typical GitHub Pages / Jekyll setup, you’d:
- Copy
python-migrate-kit.zipinto your repository’sassets/folder. - Commit and push that change.
- Make sure your Markdown link points to:
[Python Migration & Cleanup Kit (ZIP)](../assets/python-migrate-kit.zip)
Adjust the relative path if your posts live in a different directory depth.
Reusing this kit for future Python upgrades
The nice part of this approach is that it’s reusable:
- Update the
-OldPythonand-NewPythonpaths for whatever versions you’re moving between. - Run
migrate-python.ps1again for normal upgrades. - Use
Remove-All-Python.ps1only when you truly need a clean slate.
This gives you a consistent, low-drama way to keep Python current on Windows — or start over clean — without losing the tools you rely on every day.