3

Python 2 and 3 both generate bytecode in the same directory as, or __pycache__ subdirectory of scripts that you run. One reason it sucks is because it dirties source trees that I would like to keep clean for various reasons that I don't need to explain for this question (please answer this question - not questions that you imagine I have!)

I know you can disable cache generation, but that is inefficient.

Is there a way to run Python (2 or 3) but tell it to store its cache in a completely separate cache directory? Either using an environment variable or a command line flag.

This is not a duplicate of this question or this question.

Timmmm
  • 88,195
  • 71
  • 364
  • 509

1 Answers1

0

This question is answered here: https://stackoverflow.com/a/53367609/1882946

For Python <3.8, this isn't possible, but working since 3.8.

Superlexx
  • 171
  • 1
  • 3