Writing a program in Python is really simple, and when we develop a feature, especially a Python program with a form, you need to turn the Python program into a double-click EXE program. We need a third-party module Py2exe, which is the module that turns the PY into EXE. Just py2exe How to install, I do not elaborate here, directly to the official web download corresponding to the Py2exe version of Python, and then a fool-type installation, and installed after the Py2exe module is automatically added to the path of Python.
And then it's easy, we're going to create a new setup.py file under the Py file directory to be converted to EXE and paste the code in:
#coding=utf-8fromimport setupimport py2exesetup(console=["要转换的py文件名"])
Then open cmd and run the setup.py file:
D:\EclipseProjects\Learn>python setup.py py2exe
The following hints appear to indicate success:
You can then find a Dist folder in the current directory, below the exe file of your original conversion file.
If you encounter an error:
2fileordirectory‘MSVCP90.dll‘
Modify the script in the setup.py file as follows:
#coding=utf-8fromimport setupimport py2exe# setup(console=["chapter13.py"])setup(windows=["chapter13.py""py2exe":{"dll_excludes":["MSVCP90.dll"]}})
And then follow the original method of execution, you can succeed. The reason should MSVCP90.dll
not be found. This problem typically occurs after you use a program that has a form.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Use Py2exe to turn python files into exe files (and error: [Errno 2] No such file or directory: ' MSVCP90.dll ' workaround)