To completely uninstall Python and all its packages on Windows, follow these steps:
1. Uninstall Python via the Installer
If you still have the original Python installer (e.g.,
python-3.11.0-amd64.exe), run it again and select "Uninstall". This is more reliable than using "Add or Remove Programs" and ensures a clean removal of the core Python installation.
2. Remove Python from PATH and Environment Variables
Open System Properties > Environment Variables.
Under System Variables, edit the Path variable and remove any entries pointing to Python (e.g.,
C:\Python311\,C:\Python311\Scripts\, orC:\Users\<username>\AppData\Local\Programs\Python\Python311\).Remove any PYTHONPATH, PYTHONHOME, or similar variables if present.
3. Delete Remaining Python Files and Folders
Manually delete these folders if they exist:
C:\Users\<username>\AppData\Local\Programs\Python\C:\Users\<username>\AppData\Roaming\Python\C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\→ Deletepython.exe,python3.exe, andpip.exeif present.
4. Uninstall All pip-Installed Packages
Open Command Prompt and run:
pip freeze > packages.txtEdit
packages.txtand removesetuptoolsandwheel(they are required for pip to function).Run:
pip uninstall -r packages.txt -yDelete
packages.txtafter completion.
5. Verify Complete Removal
Open a new Command Prompt and run:
where python where pipIf you see "INFO: Could not find files for the given pattern(s)", Python and pip are fully removed.
⚠️ Note: If you don’t have the original installer, download the latest Python installer from python.org and use the "Modify" option to uninstall. This method ensures all components are removed properly.
If you uninstall from the control panel, it should remove all packages with it. To ensure that your path doesn't contain your old python when you try and use anaconda, you should remove Python from your path. In windows 10:
- From desktop go bottom left and find the menu.
- Click system, then Advanced System Settings
- In this window, go to the Advanced tab and click on the environment variables button.
- From there you can edit your Path, with the edit button.
- Make sure there is no reference to Python here. Also, all variables are separated by a ; so make sure all syntax is good before saving.
- Install anaconda and at the end of the install it should ask if you want to make it the default Python. Say yes and every time you or another program asks for Python, it will get pointed to anaconda.
If you uninstall from the control panel, it should remove all packages with it. To ensure that your path doesn't contain your old python when you try and use anaconda, you should remove Python from your path. In windows 10:
- From desktop go bottom left and find the menu.
- Click system, then Advanced System Settings
- In this window, go to the Advanced tab and click on the environment variables button.
- From there you can edit your Path, with the edit button.
- Make sure there is no reference to Python here. Also, all variables are separated by a ; so make sure all syntax is good before saving.
- Install anaconda and at the end of the install it should ask if you want to make it the default Python. Say yes and every time you or another program asks for Python, it will get pointed to anaconda.
What I was able to do is use the Set-up executable which installed Python. It gave me the options Install or Repair or Uninstall. Then I went to my Environmental Variables. I delete Python from my list of Paths.
I am trying to fresh start to learn python on my linux machine. Previously i tried some python and installed some modules(or packages?, i mean additional libraries) with python -m or pip command.
Now I learnt i need to install packages to a virtual environment with using pip install --user packagename. I want to clear packages that i installed to system locations but how can i find and uninstall them?
I checked /usr/lib/python3.11 /home/myuser/.local/lib/python3.11 dirs and there are more than hundred packages. And i dont know if these are the modules that i installed or some of them system modules?
python - How do I remove all packages installed by pip? - Stack Overflow
Could you pls tell me how to uninstall python 3.12.4(64 bit)
How can i do a FULL uninstall of python?
Need advice on how to completely uninstall python
Videos
Here's the steps (my non-computer-savvy girlfriend had to figure this one out for me, but unlike all the far more complicated processes one can find online, this one works)
- Open Control Panel
- Click "Uninstall a Program"
- Scroll down to Python and click uninstall for each version you don't want anymore.
This works on Windows 7 out of the box, no additional programs or scripts required.
You will also have to look in your system path. Python puts itself there and does not remove itself: http://www.computerhope.com/issues/ch000549.htm
Your problems probably started because your python path is pointing to the wrong one.
I've found this snippet as an alternative solution. It's a more graceful removal of libraries than remaking the virtualenv:
pip freeze | xargs pip uninstall -y
In case you have packages installed via VCS, you need to exclude those lines and remove the packages manually (elevated from the comments below):
pip freeze --exclude-editable | xargs pip uninstall -y
If you have packages installed directly from github/gitlab, those will have @.
Like:
django @ git+https://github.com/django.git@<sha>
You can add cut -d "@" -f1 to get just the package name that is required to uninstall it.
pip freeze | cut -d "@" -f1 | xargs pip uninstall -y
This will work for all Mac, Windows, and Linux systems. To get the list of all pip packages in the requirements.txt file (Note: This will overwrite requirements.txt if exist else will create the new one, also if you don't want to replace old requirements.txt then give different file name in the all following command in place requirements.txt).
pip freeze > requirements.txt
Now to remove one by one
pip uninstall -r requirements.txt
If we want to remove all at once then
pip uninstall -r requirements.txt -y
If you're working on an existing project that has a requirements.txt file and your environment has diverged, simply replace requirements.txt from the above examples with toberemoved.txt. Then, once you have gone through the steps above, you can use the requirements.txt to update your now clean environment.
And For single command without creating any file as @joeb suggested
pip uninstall -y -r <(pip freeze)
Dear u/daddy_spez,
I am going to reinstall python but there are things the uninstaller just doesn't remove.
The pip packages are there, the PATH is there, some leftover files are still there and who know what else is in the system.
I want to fully uninstall python so i can reinstall it and all the packages i got, if i re-install while all these things are still there it will create conflicts and things that once worked will be bugged.
so im on win10 and running python 3.8.3 and my pip suddenly stopped working and couldnt get it to work anymore. i tried lots of things but sadly nothing .
so i would like to completely remove python ( and the cache or whatever will be scattered or left behind by the installer) . anyone can help me on this
Please don't.
Ubuntu relies heavily on different Python versions for functionality. New releases of Ubuntu are slowly shifting to Python3, but older versions of Python are still in use.
You can list some important Ubuntu and Gnome packages on your system that depend on Python3, for example, like so:
apt-cache rdepends -i --installed --recurse python3 | \
grep -v " " | sort -u | grep -E "ubuntu|gnome"
On Ubuntu 20.10 desktop, these important packages are among them:
gnome-control-center
gnome-session
gnome-terminal
network-manager-gnome
ubuntu-desktop
ubuntu-desktop-minimal
ubuntu-drivers-common
ubuntu-minimal
ubuntu-release-upgrader-core
ubuntu-release-upgrader-gtk
ubuntu-session
ubuntu-standard
ubuntu-system-service
Moreover, there is no such Python clean state. Each system update and each package you install might bring with it Python related dependencies.
You can however use pip or pip3 to uninstall only packages you previously manually installed and even this is not totally risk free.
If you have already removed Python, try this or this if you need a fix. Chances are little though. If you manage to fix it, you are lucky.
Golden rule... Leave the snake alone.
That being said, use a Python virtual environment for your Python projects and you shouldn't be needing to clean or go back to clean state Ubuntu system Python.
Python virtual environments create an isolated environment for your Python projects. This means that each project can have its own dependencies, regardless of what dependencies the Ubuntu system or other Python projects have.
This feature can be installed for Python3 like so:
sudo apt install python3-venv
To make a Python3 virtual environment for a project, you would first create a directory and cd to it like so:
mkdir my_env && cd my_env
Then, create a new Python3 virtual environment inside the directory like so:
python3 -m venv env
This will create a structure like this:
$tree -L 3
.
└── env
├── bin
│ ├── activate
│ ├── activate.csh
│ ├── activate.fish
│ ├── Activate.ps1
│ ├── easy_install
│ ├── easy_install-3.8
│ ├── pip
│ ├── pip3
│ ├── pip3.8
│ ├── python -> python3
│ └── python3 -> /usr/bin/python3
├── include
├── lib
│ └── python3.8
├── lib64 -> lib
├── pyvenv.cfg
└── share
└── python-wheels
To use this environment, activate it like so:
source env/bin/activate
Your shell prompt will show (env) like so:
(env) $
During this, Python3 commands, module installs or modifications will be contained locally in this virtual environment.
When you are done, deactivate this Python3 virtual environment like so:
deactivate
You are now back to the system-wide Python3 and commands will take effect globally so be careful.
Here's a method:
get 'apt-cache' to show reverse-dependencies, recursively, of the core python library; "--installed" to limit to packages installed, and "-i" to show only important dependencies (i.e. not suggests or recommends).
The 'grep' filters out all except package names, then sorted uniquely (there'll be many duplicates), then use 'xargs' to append the resulting list of lines as parameters to 'apt-mark auto', which marks them as automatically installed.
'Automatically installed' packages will be removed by 'apt autoremove' when no more packages depend on them.
apt-cache --installed -i --recurse rdepends \
libpython3.8-minimal | \
grep "^ " | sort -u | \
xargs apt-mark auto
apt autoremove
This will show the long list of packages to be removed, be careful of unexpected dependencies removing packages you want to keep!
Say 'no' to that prompt and 'apt-mark manual ThisOne' for all the packages you need to keep, and run 'apt autoremove' again (and check again!) to get rid of the junk.