Basic usage of PyInstaller and Pyarmor
KodoOjiEngineer
Posted on December 14, 2021
Pyinstaller and Pyarmor
Pyinstaller and Pyarmor are two tools that can be used to create GUI tools using Python, or to convert your code into an exe file for distribution.
Pyinstaller turns your python code into an exe file on windows, or an app file on mac, and Pyarmor obfuscates the code before turning it into an exe if you don't want people to know what's in the code.
I had a chance to use it at work, so I'll share it with you along with my personal notes.
Both are not Cross Platform.
Both Pyinstaller and Pyarmor are not cross platform. Therefore, you have to exe and app them on Windows, Mac and Linux respectively.
It is also important to make sure that the OS versions match (I was unable to run the app on Catalina when I made it on Big Sur).
(If you are using the Fastapi framework, pip install websocket==8.1
was required, due to the use of uvicorn?)
Command differences by environment
flask
┝ __init__.py
└ app.py
For simplicity, let's assume a Flask application like the one above.
-
If you have installed python or pythol library in your local environment
- Pyinstaller
under /flask,
pyinstaller app.py
- Pyarmor
under /flask,
pyarmor pack -e " --onefile" app.py
- Pyinstaller
under /flask,
-
If you are installing Python and python library under Poetry environment
- Pyinstaller
pyinstaller app.py
- Pyarmor
pyarmor pack -e " --onefile" -x " --exclude venv --no-cross-protection" app.py
(need to exclude .venv file)
- Pyinstaller
License of Pyarmor
You need to purchase a license for commercial use.
It is a one-time purchase and costs about $70 (us doller). If I buy one, can I use it for more than one?
There's not much information on Pyarmor, and I had a hard time figuring out how to Build it, especially in a poetry environment!
I hope this helps someone out there!
Posted on December 14, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.