Eliminate Python __pycache__ directories
Python can put all Python .pyc cache files under one system-wide directory by the PYTHONPYCACHEPREFIX environment variable.
- Windows: set environment variable
PYTHONPYCACHEPREFIXto%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
PYTHONDONTWRITEBYTECODEto1 - Linux: in ~/.profile add
export PYTHONDONTWRITEBYTECODE=1 - macOS: in ~/.zshrc add
export PYTHONDONTWRITEBYTECODE=1