Changing the directory where .pyc files are created

Scharron picture Scharron · Aug 19, 2010 · Viewed 17.4k times · Source

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 to be implemented in the default interpreter (I'm working with Python 3).

Did I miss something ?

Answer

Hans picture Hans · Aug 29, 2011

This might be useful for some: Miscellaneous options, especially -B option:

If given, Python won’t try to write .pyc files on the import of source modules. See also PYTHONDONTWRITEBYTECODE.