DEV Community

KodoOjiEngineer
KodoOjiEngineer

Posted on

Basic usage of PyInstaller and Pyarmor

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
Enter fullscreen mode Exit fullscreen mode

For simplicity, let's assume a Flask application like the one above.

  • If you have installed python or pythol library in your local environment

    1. Pyinstaller under /flask, pyinstaller app.py
    2. Pyarmor under /flask, pyarmor pack -e " --onefile" app.py
  • If you are installing Python and python library under Poetry environment

    1. Pyinstaller pyinstaller app.py
    2. Pyarmor pyarmor pack -e " --onefile" -x " --exclude venv --no-cross-protection" app.py (need to exclude .venv file)

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?

PyArmor License

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!

Top comments (0)