cool hit counter Procedural steps for packaging Python programs into executable applications_Intefrankly

Procedural steps for packaging Python programs into executable applications

Today we recommend you an important library in Python - pyinstaller, this library has an important role in team project development to improve development efficiency, so focused python developers must know how to use it.

So what is pyinstaller? pyinstaller is a very useful python packaging tool that can package python scripts into an exe executable file in Windows environment, and the various third-party libraries that the scripts depend on are handled together in a unified way when packaging, so that the packaged exe file can be executed on computers without these libraries installed, or even on computers without any python environment installed.

Here we will explain how to install and use pyinstaller to complete the packaging of our python program

1 Install pyinstaller

In the previous section we talked about how to install Anaconda, based on the development platform already installed in the previous section, first open the AnacondaPrompt command window and use the following command to install pyinstaller

pip install pyinstaller

2 pyinstaller.exe to package the file

Once the pyinstaller library is installed, we need to package our file into a XXX.exe file, by executing the following command.

pyinstaller.exe -F

Here we focus on the usage of pyinstaller.

--F means generate a single executable file

--w means remove the console window, which is useful when the GUI interface is in use. But if it's a command line program then remove that option!

--p means you customize the path to the class you need to load, which is not normally used

-i indicates the icon of the executable file

3 The executable was successfully generated

The XXX.exe executable is successfully compiled and generated when we see the following screen.

4 Run XXX.exe with an error

Clicking on XXX.exe, just when we thought XXX.exe would run properly, the following error appeared.

5 Resolving Errors

Because my code references the pandas library, and then when I use pyinstaller to package it, it shows that the package is successful, but the actual runtime shows that the module is missing, so we need to modify the original package code as follows.

Compile and run again

6 compile successfully, generate xxx.exe

7 Run xxx.exe again, and the following screen appears successfully.

In operation.

The program finished executing and found an extra .csv file under the folder

8 Finally, the generated exe file is ported to a colleague's computer and also works fine

At this point, we have packaged a script file developed in python, such an exe file on any computer can run properly, without the need to install other dependencies, amazing, right? In the next section we'll bring you python image recognition, so stay tuned!!!

A quick introduction to big data and hands-on AI focus on it!

1、Configuring python multiple versions under Mac
2、Talking about OAuth 20based thirdparty authentication Medium
3、html learning cssclass selector
4、Difference between tailf tailf and tailF
5、NetEase BOBO Building an Entertainment Dream Factory on the Internet

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送