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