I am referring to this stackoverflow answer
How to obfuscate Python code effectively?
python -OO -m py_compile <your program.py>
It said a .pyo new file should be produced but I am not getting any new file or any errors..
what is wrong?
I am referring to this stackoverflow answer
How to obfuscate Python code effectively?
python -OO -m py_compile <your program.py>
It said a .pyo new file should be produced but I am not getting any new file or any errors..
what is wrong?
It's hard to tell exactly the root cause of this error. I have just run a test in a similar environment to yours and it works perfectly fine.
It, however, does not output a file of type .pyc
instead, it outputs a folder named __pycache__
in which it contains the compiled python file
. Check if this folder is created in your directory; it is most likely that it will.
Side note: As someone mentioned in the comments, consider using this instead as it is able to recover full source code
I faced this issue on macOS. I found the __pycache__
directory here:
/Users/Scaroth/Library/Caches/com.apple.python/Users/Scaroth/src/py/the_script.cpython-38.pyc
I tracked this down by looking at the module's source here:
/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/py_compile.py
Then noticed this comment:
cfile: The target byte compiled file name. When not given, this defaults to the PEP 3147/PEP 488 location.
and realised compile()
actually returns cfile
A print(cfile)
yielded...
/Users/Scaroth/Library/Caches/com.apple.python/Users/Scaroth/src/py/the_script.cpython-38.pyc