I already added the following snippet to the top of my python codes to prevent pycache files from being generated.
import sys
sys.dont_write_bytecode = True
Now, if I run the files (unit tests) individually, no pycache file is generated. However, as soon as I use the Testing feature of VS Code to run all unit tests one after another, it consistently generates a pycache folder.
Thanks in advance for any help!
CodePudding user response:
Reasons for Pycache folder generation
When B.py import A.py, there will generate a A.pyc
How to avoid .pyc files
python3 -B test.py
Use this command run the .py file.- add the following code into the .py file:
import sys sys.dont_write_bytecode = True
Setting environment variables
PYTHONDONTWRITEBYTECODE=1
According to your situation, I suggest you tring the third way to avoid the .pyc file.