XZ_Python packages Python scripts into executable files

Because of the Python script written, Python may not be installed on other people's computers, or the relevant class library may not have been introduced, resulting in the failure of the Python script to run or the user will not run it. Therefore, I thought of packaging the Python script into an executable file. , so that the user only needs to double-click the program, and nothing else needs to be done.

I use pyinstaller to package the Python script into an executable file, and the following are the steps to achieve it:

1. Install pyinstaller, enter the terminal: pip install pyinstaller


2. After the installation, you can view the version and enter the terminal: pyinstaller --version


3. Execute the package, enter the terminal: pyinstaller -F /Users/admin/Desktop/Python package/Python package into executable file/RecommendGUI.py

After the execution, you will see two more folders in the folder, one is build, the other is dist, and the executable file is in the dist folder. You can send this executable file to others. After someone double-clicks, it will be executed automatically, and nothing needs to be done.


However, this executable file can only be executed normally under the same conditions as your computer system, otherwise it cannot be executed.

For example, my iMac version is 10.13.1,


I send the executable file to the computer system whose system version is 10.12.6, and the following error occurs:


However, it can be executed on a computer with the same system version as mine, and there is no problem, so a similar error as shown in the above figure appears, indicating that the computer system of the currently executing file should be adapted separately when packaging.

Reference article: https://www.cnblogs.com/mywolrd/p/4756005.html

2018--5--3

After the system is upgraded, the previously packaged executable files can still be executed, indicating that they are upward compatible and not downward compatible.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325918101&siteId=291194637