I'm setting the PYTHONDONTWRITEBYTECODE
environment variable to avoid .pyc files, and I have checked that sys.dont_write_bytecode
is True.
But .pyc files are still generated everywhere.
PS: I'm using Python 2.6.6
The reason is that my script is running under env -i
.
It should appear before importing your modules. I have moved it to the top of code and it works.
#!/bin/python
import sys
sys.dont_write_bytecode = True
import myModule
It could be that you are mispelling the env variable? PYTHONDONTWRITEBYTECODE
This works:
PYTHONDONTWRITEBYTECODE=1 python -c "import test"
So does this: python -B -c "import test"
And when running a script directly which imports test.py:
./importer.py
importer.py
#!/usr/bin/env python -B
import test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With