This Python script creates a detailed Python installation and environment audit report. It examines the active Python interpreter, virtual environments, PATH settings, Anaconda installation, Conda configuration, and related environment variables.
The script writes the audit results to a text report file for troubleshooting and documenting the Python environment configuration.
The script uses Python built-in libraries including os, sys, subprocess, pathlib, contextlib, and datetime. These modules support system inspection, file handling, command execution, output redirection, and report generation.
The script creates:
The report contains information about the installed Python environment, Anaconda installation, Conda settings, and system configuration.
The generated report includes the following sections:
PYTHON or containing
CONDA.
where commands to locate Python and Conda executables.
python.exe and
conda.exe.
with
try/except
pathlib.Path
subprocess
print_header()
datetime.now()
Path.exists()
subprocess.run()
where python and
where conda.
redirect_stdout()
This script demonstrates a practical Python system-audit workflow. It combines operating system inspection, environment analysis, file handling, and report generation to document a Python installation.
The resulting report is useful for diagnosing Python, Anaconda, and Conda environment configuration issues.