Changing the directory where .pyc files are created

Yes, starting from Python 3.8 you can control this behavior. The original discussion starts from pep 304 in 2003.

While this original PEP was withdrawn, a variant of this feature was
eventually implemented for Python 3.8 in

In the result, you can control using PYTHONPYCACHEPREFIX=path, -X pycache_prefix=path and sys.pycache_prefix.

Leave a Comment