Despite being an experienced developer, we all make mistakes. This script is designed to help clean up Python environments by uninstalling all packages that are not part of the standard library, keeping your global and virtual environments clean.
- Mistakenly installing packages in the global environment
- Installing packages in the wrong virtual environment
- Installing packages for the wrong version of Python
- Creating a virtualenv in the wrong directory, affecting other projects
curl -s https://raw.githubusercontent.com/sadaqatullah/global-python-cleaner/refs/heads/master/cleaner.py | sed 's/input("Do you want to proceed? (y\/n): ").lower()/"\&\#x79;"/' | python3 - --auto-confirm
curl -s https://raw.githubusercontent.com/sadaqatullah/global-python-cleaner/refs/heads/master/cleaner.py | sed 's/input("Do you want to proceed? (y\/n): ").lower()/"\&\#x79;"/' | python3 - --auto-confirm --keep <space-separated-package-names>
curl -s https://raw.githubusercontent.com/sadaqatullah/global-python-cleaner/refs/heads/master/cleaner.py | sed 's/input("Do you want to proceed? (y\/n): ").lower()/"\&\#x79;"/' | python3 - --auto-confirm --keep django
Output:
The following packages will be kept:
- setuptools
- django
- pyenv
- wheel
- pip
- virtualenv
The following packages will be uninstalled:
- package-1
- package-2
...
- package-n
Cleanup completed.
--keep
argument.
-
Clone the repository:
git clone https://github.com/sadaqatullah/global-python-cleaner.git cd global-python-cleaner
-
Choose one of the following approaches:
python cleaner.py
python cleaner.py --keep <space-separated-package-names>
-
When prompted, type
y
to proceed with the uninstallation of packages.
--keep
argument.
Contributions to improve the Python Environment Cleaner are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.
Created with ❤️ by Sadaqatullah