Eliminate Python __pycache__ directories
Python ≥ 3.8 can put all Python .pyc cache files under one system-wide directory by the PYTHONPYCACHEPREFIX environment variable.
- Windows: set environment variable
PYTHONPYCACHEPREFIX
to%TEMP%
- Linux: in ~/.profile add
export PYTHONPYCACHEPREFIX=${TMPDIR}
- macOS: in ~/.zshrc add
export PYTHONPYCACHEPREFIX=${TMPDIR}
Pycache .pyc files can be set to NOT write anywhere with the PYTHONDONTWRITEBYTECODE environment variable.
- Windows: set environment variable
PYTHONDONTWRITEBYTECODE
to1
- Linux: in ~/.profile add
export PYTHONDONTWRITEBYTECODE=1
- macOS: in ~/.zshrc add
export PYTHONDONTWRITEBYTECODE=1