Cx_freeze download site is http://sourceforge.net/projects/cx-freeze/files/, want to undertake choosing according to install python version. For example, I am using python3.1, so I will download the file cx_Freeze- 22.214.171.124.win32-py3.1.msi. After running the installation package, the program is copied to the Python directory. There are two main places, one is C:/Python31/Scripts and the other is C:/Python31/Lib/site-packages/cx_Freeze
In previous versions of cx_Freeze, py was converted to exe through the script Freezepython.py, but in 4.2.2 Freezepython.py is gone and the main work is done by the C:/Python 31/scripts cxfree.bat.
There are two main ways to complete python exe packaging using cx_Freeze:
First, run cxfreeze. Bat directly through:
Go to the CMD command line, enter the C:/Python 31/scripts directory, and run cxfreed.bat-h to see its instructions. We can do an experiment with CX_freeze’s own sample.
Go to C :/ Python 31/scripts/ and run
cxfreeze C:/Python31/Lib/site-packages/cx_Freeze/samples/PyQt4/PyQt4app.py –install-dir=d:/123
Pytqt4app.py is packaged as exe, and the libraries it USES are also evaluated in the d:/123 directory.
Second, run setup.py:
In the example provided with CXfreeze C:/ python31/lib /site-packages/cx_Freeze/samples/PyQt4, there is a setup.py file. Open this file and we find that it is:
By running this script, packaging can be done automatically:
For example, if you go into C:/ python31/lib /site-packages/cx_Freeze/samples/PyQt4,
After that, a build/exe.win32-3.1 directory will appear under this directory, where you can see the packaged exe file. We want to package our script, copy this setup.py over, and put it in
executables = [Executable(“PyQt4app.py”, base = base)])
Change pyqt4app.py to your own script name.
Problems during packaging:
For Chinese support, if there is Chinese in the script and the encoding format is not specified, the packaging process will occur: UnicodeDecodeError: ‘utf8’ codec can ‘t decode bytes in the position of 1602: invalid data this kind of mistake, this blog post on http://www.cnblogs.com/xinzaitian/archive/2010/12/10/1902481.html, the author mentioned Chinese must be deleted.
In fact, Chinese characters can be retained by adding the following at the beginning of the script file:
#! /usr/bin/env python
It is ok
Another problem is that if the packaged EXE file is run under “desktop” or other Chinese path, a window will pop up showing “Cannot get zipimporter” instance. So far, no good solution has been found
- Python – writing visual interface (Python + pycharm + pyqt)
- Python 3 install pyqt5
- Installing PyQt4 in Windows + Python 3.6
- Error occurred when Python installed the pocketsphinx module (package): Command‘ swig.exe “Failed: no such file or directory
- When python installs pocketsphinx module (package), an error is reported: command ‘swig.exe’ failed: No such file or directory
- Record the python package EXE file running error importerror, but do not prompt specific error solution
- Can’t find Python executable “D:\python3\python.exe”, you can set the PYTHON env variable.
- Under win864 bit, install python, PyQt4 and sip. (final failure, only record)
- Python packaged *. Exe is running os.popen (cmd)/ subprocess.Popen *. Exe crashes with invalid [winerror 6] handle
- Solve the problem of unable to locate package python3.6 when upgrading from python3.5 to python3.6 in ubantu16.04
- Python uses cxfree to package script files into executable programs
- Making Python script into exe command under Windows
- Install python’s C extension compilation environment under windows (solve “error: command’cl.exe’ failed: No such file or directory”)
- Error in pyinstall package Python program: jinja2.exceptions.templatenotfound: Chart_ Solution to component.html
- Install Python C extension compiler environment under windows (solve “error: command” cl.exe ‘ failed: No such file or directory”）
- Idea Maven project uses package to package and report error (package does not exist)
- The problem of failed to create process occurs in pyinstaller package program of Python
- Package summary of installing python with CONDA
- Install Python package under MacOS: “error: Command ‘GCC’ failed with exit status 1”
- When using exe4j to generate exe executable file from jar, no JVM could be found on your system exception appears