1

I would like to prevent python from automatically creating __pycache__ directories. From some searching, I have learned that I need to set the PYTHONDONTWRITEBYTECODE python environment variable.

In a Windows environment, is this set the exact same way I would set any other system environmental variable (such as PATH)? If not, how can I set this variable so that any time I run python this is set?

1 Answer 1

3

Err, the simple answer while trying to make this at least 30chars is - Yes. (It doesn't matter what it's set to, as long as it's set - although 1 would probably be reasonable).

If you don't want to do it on a system level/user level basis, then you can always run python with the -B option.

Sign up to request clarification or add additional context in comments.

4 Comments

Great, thanks! I knew about the -B option, but it's hard to do that when I double-click the script to run it. :)
@Darthfett you may want to consider setting up a .cmd file which is a simple wrapper around calling Python but with the -B set... if you want a project by project basis setting...
@Darthfett You could also change the run-with settings to include -B - long time since I've used windows though
that's a good idea for other Windows users. On this machine/project, I don't really write much python though, so I don't really need it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.