I am using python 3.6.
I have below directory structure:
test_run.py
addition --> add.py
I have test_run.py file which is importing one of the function called add_values()
from add.py
present inside Addition
directory or package.
Code for test_run.py
and add.py
is as below:
test_run.py
:
from addition.add import add_values
print(add_values(5,4))
add.py
:
def add_values(a,b):
return (a+b)
I compiled everything using cpython compileall to create a .pyc file for each python file. Because I want to get rid of all python files and use only byte code files or compiled files.
test_run.py
created test_run.cpython-36.pyc
and add.py
created add.cpython-36.pyc
.
Then I deleted actual python files (test_run.py
and add.py
) and ran compiled file test_run.cpython-36.pyc
but it is giving me error:
ModuleNotFoundError: No module named 'addition.add'
It works fine with source files (test_run.py), it fails only when I run bytecode file(test_run.cpython-36.pyc) without source files(after deleting the source files)
Please guide me how do I get rid of original python files and use only byte code files? I want to achieve complete obfuscation of code.