Changing the directory where .pyc files are created

后端 未结 4 1975
天涯浪人
天涯浪人 2020-12-08 19:05

Is there a way to change the directory where .pyc file are created by the Python interpreter? I saw two PEPs about that subject (0304 and 3147), but none seems

4条回答
  •  星月不相逢
    2020-12-08 19:43

    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 https://bugs.python.org/issue33499

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

提交回复
热议问题