Python compiled into a Windows EXE executable file

Source: Internet
Author: User

Pyinstaller is a tool used to package the Pyhon program as an EXE file, Pyinstaller is not a python package, just need to download the Pyinstaller file and put it to any possible, That is to say pyinstaller equivalent to separate out of the specialized dry packaging Python tools, this goods is a tool is not a library, I would like to introduce the Pyinstaller installation method

Pyinstaller is a tool used to package the Pyhon program as an EXE file, Pyinstaller is not a python package, just need to download the Pyinstaller file and put it to any possible, That is to say, Pyinstaller is the equivalent of independent out of the specialized dry packaging Python tools, this goods is not a library, not a package ...
1. Download and install pyinstaller, download URL: http://www.pyinstaller.org/to download, Then extract to any directory. (Note: Before pyinstaller2.0 version If you move this folder, you need to change some configuration, otherwise pyinstaller will not be used because of your mobile.) This is related to the configuration environment behind. pyinstaller2.0 version is not limited.
2. Compile the configuration environment (extract to F: Disk for example)
①, pyinstaller-2.0 Method:
Open the CMD CD into the extracted directory under Sorce, namely: CD F:pyinstaller-2.0source
Run python./waf Configure Build Install
* (You may need to install Pywin32. Download and install, rerun the command)


②, pyinstaller-1.5
Open cmd CD into Pyinstaller unzip directory, CD f:pyinstaller-1.5
Run Python configure.py
* (You may need to install Pywin32. Download and install, rerun the command)
The result prompt is saved in the Config.dat file. Where the Config.dat file is stored in the root directory of the Pyinstaller.
3. Package The PY program you wrote EXE
①, pyinstaller-2.0 Method:
Copy the py file (helloworld.py) you wrote to the Pyinstaller extract directory,
Open the CMD CD into the extracted directory, namely: CD f:pyinstaller-2.0
Run command python pyinstaller.py [opts] yourprogram.py
Here is the run: Python pyinstaller.py [opts] helloworld.py
In the directory will generate a HelloWorld folder, which contains Helloworld.spec files, two folders (Dist,buildi), can run EXE is placed under/dist/yourprogram


②, pyinstaller-1.5
Copy the py file (helloworld.py) you wrote to the Pyinstaller extract directory,
Open the CMD CD into the extracted directory, namely: CD f:pyinstaller-1.5
The difference between pyinstaller-1.5 and pyinstaller-2.0 came.
In the pyinstaller-1.5 you need to generate the spec file, and then through the spec file in the generation of EXE files, and pyinstaller-2.0 in the execution of commands (see above) will be at the same time EXE and spec files are generated.
So in pyinstaller-1.5 you have to mister into spec file:
Python makespec.py [opts] yourprogram.py
Run command: Python makespec.py [opts] helloworld.py
At this time the HelloWorld folder is generated under this directory, there is a Helloworld.spec file under the folder, the file is copied to the directory (f:pyinstaller-1.5)
Run command: Python build.py helloworld.spec
4. You will find that according to the above method under/yourprogram/dist/yourprogram in addition to the required EXE file, there are many DLL files, and then you will start to complain about the author I Hang dad ....
Haha, if you find out so, the description, you have finished with the most basic pyinstaller packaging, about how Pyinstaller please look down:
Whether it's pyinstaller-1.5 or pyinstaller-2.0, you want to package a file, or modify the file's icon, and so on, which is related to when you run the command, remember what the command is?
Pyinstaller-2.0 is:
Python pyinstaller.py [opts] yourprogram.py
pyinstaller-1.5 is:
Python makespec.py [opts] yourprogram.py
Those that are packaged as a file, or that change the icon of a file, and so on, are related to this [opts].
Here are some examples (sir, with pyinstaller-2.0 as an example, 1.5 general):
①, packaged into a file:
Python pyinstaller.py–onefile yourprogram.py
②, modify the EXE's icon (D:babywandhsrcfaviconw.ico is the storage path for the icon):
Python Pyinstaller.py–onefile–icon=d:babywandhsrcfaviconw.ico yourprogram.py
[opts] Some instructions (specifically can see Pyinstaller official website Http://www.pyinstaller.org/expor ... talling-pyinstaller):


Python compiled into a Windows EXE executable file

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.