Pyinstaller Package A python file into an. exe program

Source: Internet
Author: User

Use Pycharm written code, each time to use the pycharm to do more trouble, packaged as an. exe program can be run directly, can also be sent to other computers to execute, more convenient. 1. Open the cmd Command Prompt window, CD to the directory where Pip.exe is located, install the Pyinstaller module using the Pip.exe install Pyinstaller command (provided your computer has Python installed), After the installation is complete, many py files are generated in the directory.

2. Use the command pyinstaller-c-F weixin.py to generate a Weixin.exe program

    • After execution, two folders are generated in the current directory, where the. exe file is in the Dist folder

3. Perform a look at the effect

    • Can be successfully executed, the calling browser successfully opened the destination URL, enter the account password in the Run box, and then scan the code to log in to the public number.
4. Problem handling
    • Before packaging into EXE to perform error, in fact, it took nearly one hours to solve the problem of failed to Excute script Weixin.
    • Because in my code, to invoke the browser driver to open the Google Browser, but I did not put the driver in the current directory (and the Pyinstaller program in the same directory), PY file weixin.py should also be placed in this directory, do not put in this directory, in the execution of the command to use the absolute path of the py file.
    • where the Code
Parameter options for 5.pyinstaller

By the way, the role of several parameters

-F: A separate EXE file is generated directly, with no dependent files attached.

-C: The generated EXE file opens in the console.

-W: This corresponds to the above-C, if your program has a UI, then use this-W. This does not appear in the console and is directly your UI.

-I: Add an icon to your EXE file, followed by the ICO file you want.

-P: followed by the module search path you want to specify, if your module installation path is not automatically retrieved by Pyinstaller, you need to specify it yourself.

Pyinstaller Package A python file into an. exe program

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.