Direct .pyc files to different directories when .py script is run<>
This question already has an answer here:
You cannot. .pyc files can only be written to the same location as the source file.
Python 3.2 moved to a __pycache__ subdirectory instead. Neither option is configurable.
At best you can disable bytecode files being written by either removing write access to the directory, setting the -B command line option when you run Python, or setting the PYTHONDONTWRITEBYTECODE environment variable.