Skip to content

R-Priyadarshan/python-package-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Windows Python Installation & Package Size Analyzer

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.


Features

  • Multi-Source Python Detection:
    • Windows Registry (HKCU and HKLM under Software\Python\PythonCore).
    • Python Launcher (py -0p).
    • System PATH environment variable.
    • Common installation directories (%LocalAppData%\Programs\Python, %ProgramFiles%\Python, C:\Python*).
    • Anaconda, Miniconda, and Mamba environments.
    • Virtual environments (.venv, venv, env directories searched locally and in user profile).
  • 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.
  • 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.

Requirements

  • Operating System: Windows (CMD or PowerShell)
  • Python Version: Python 3.9+ (compatible with the running interpreter)

Quick Start

  1. Clone or download the repository.
  2. Run the script from PowerShell or CMD:
python analyze_pythons.py

Command-Line Arguments

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

Example Output

============================================================
  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
============================================================

License

This project is open-source and available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages