A standalone, production-grade Python utility designed for Windows systems to scan, detect, and analyze all installed Python interpreters and calculate the precise disk usage of packages in their site-packages directory.
- Multi-Source Python Detection:
- Windows Registry (
HKCUandHKLMunderSoftware\Python\PythonCore). - Python Launcher (
py -0p). - System
PATHenvironment variable. - Common installation directories (
%LocalAppData%\Programs\Python,%ProgramFiles%\Python,C:\Python*). - Anaconda, Miniconda, and Mamba environments.
- Virtual environments (
.venv,venv,envdirectories searched locally and in user profile).
- Windows Registry (
- Accurate Disk Usage Calculation:
- Runs in a subprocess inside the target interpreter to extract package versions and files using
importlib.metadata. - Fallback to offline directory scanning via a fast, non-recursive folder size calculator if the interpreter is broken or incompatible.
- Runs in a subprocess inside the target interpreter to extract package versions and files using
- Visual Terminal Interface:
- Clean, ANSI-colored output showing a table of packages sorted by size in descending order.
- Highlights the 20 largest packages for each Python installation.
- Displays total disk space used by all packages for each interpreter.
- Data Export:
- Automatically exports the complete analysis results to a CSV file.
- Safety First:
- Entirely read-only; does not modify, update, or delete any files or packages.
- Handles permission errors, missing directories, and symbolic links gracefully.
- Operating System: Windows (CMD or PowerShell)
- Python Version: Python 3.9+ (compatible with the running interpreter)
- Clone or download the repository.
- Run the script from PowerShell or CMD:
python analyze_pythons.py| Argument | Description | Default |
|---|---|---|
--csv <path> |
Path where the CSV report will be saved | python_packages_report.csv |
--limit <num> |
Number of largest packages to highlight per installation | 20 |
--all |
Show all packages in the terminal, bypassing the limit | False |
Example of showing all packages:
python analyze_pythons.py --all============================================================
Windows Python Installation & Package Size Analyzer
============================================================
Searching for Python installations on your system...
Found 3 Python interpreter(s). Analyzing package sizes...
[OK] Analyzed: Python 3.11.7 (C:\Users\...\Python311\python.exe)
[OK] Analyzed: Python 3.14.6 (C:\Python314\python.exe)
============================================================
ANALYSIS RESULTS
============================================================
Python 3.11.7
Path: C:\Users\...\Python311\python.exe
Total package size: 2.93 GB
------------------------------------------------------------
Package Version Size Path
------------------------------------------------------------
torch 2.8.0 1.24 GB ...\site-packages\torch-2.8.0.dist-info
catboost 1.2.8 360.3 MB ...\site-packages\catboost-1.2.8.dist-info
scipy 1.16.2 136.9 MB ...\site-packages\scipy-1.16.2.dist-info
transformers 4.57.1 106.8 MB ...\site-packages\transformers-4.57.1.dist-info
... and 197 more packages.
============================================================
Report successfully exported to CSV:
C:\Users\...\python_packages_report.csv
============================================================
This project is open-source and available under the MIT License.