Closed daun-io closed 5 years ago
After the package is obfuscated, pyinstaller could not find any other imported module except __init__.py
.
Try to use he pyarmor command pack
in this case:
# before run command pack, remove the obfuscated package.
pyarmor pack -e " -n my_app" -s "my_app.spec" entry_point.py
Note that you couldn't pack the obfuscated scripts, once the scripts have been obfuscated, pyinstaller could not find the dependent modules.
Refer to https://pyarmor.readthedocs.io/en/latest/man.html#pack https://pyarmor.readthedocs.io/en/latest/pack-obfuscated-scripts.html
Thanks for the answer :)
I've tried to pack it with pyarmor command pack
and it actually worked, I was able to execute the packed executable. However, when I tried to investigate the internals using decompiler and then it turned out that the only entry_point.py
is hidden and my_package
, which includes core source codes which I intended to encrypt wasn't really encrypted at all.
Is there any way to encrypt dependent packages?
I'm guessing that I can use pyinstaller's "hidden-import" option to help pyinstaller finding other dependent modules with obfuscated packages.
Please upgrade to v5.5.2, this issue has been fixed in this version.
I've upgraded to v5.5.2 and recompiled my package with this code
# before run command pack, remove the obfuscated package.
pyarmor pack -e " -n my_app" -s "my_app.spec" entry_point.py
and then my my_app.exe
raised ModuleNotFoundError: No module named 'my_package'
which means it isn't bundled inside of the pyinstaller executable however I found that dist/obf/dist
includes correctly obfuscated scripts of my_package
so I copied them to dist/my_app
and it worked which means it's importing obfuscated package from outside of the pyinstaller bundle.
I think my issue is kinda solved since I was able to make my_package
obfuscated and the entry_point is fully packaged.
But can I pack obfuscated my_package
inside the pyinstaller bundle?
The dependent package my_package
should be bundled to executable file by command pack
automatically.
First try to bundle your application with pyinstaller directily, for example
pyinstaller --clean -y -n my_app entry_point.py
cd dist/myapp
./myapp
If it works, try to pack by parmor,
rm -rf dist/ my_app.spec
pyarmor pack -e " -n my_app" -s "my_app.spec" entry_point.py
cd dist/myapp
./myapp
Note that entry_point.py
isn't obfuscated scripts, once it's obfuscated, all the dependent modules and packages couldn't be found
Generally if the python script could be bundle by PyInstaller, it could be packed by pyarmor. Just pass the extra options of PyInstaller by -e
Thanks for the answer :) I've found that the reason I wasn't able to pack obfuscated package was because I didn't properly uninstall the package which was installed inside of my python environment which prevented referencing locally obfuscated package. I'll close the issue 👍
I've obfuscated my python package "my_package" with entry point "init.py" file and it has worked really great within pyhton interpeter like this.
And then I create an external entry point which does simple thing like this
it still worked great, and then I wanted to compile this entry_point.py with pyinstaller.
and then the compiled entry_point.exe prints an error like this:
Is there any tips to solve this?