python3使用cxfreeze打包
/root/hhhh.py为源代码文件,打包过程如下:
[root@testos ~]# cxfreeze-quickstart
Project name: abc
Version [1.0]:
Description: abc
Python file to make executable from: /root/hhhh.py
Executable file name [/root/hhhh]:
(C)onsole application, (G)UI application, or (S)ervice [C]: C
Save setup script to [setup.py]:
Overwrite setup.py [n]? y
Setup script written to setup.py; run it as:
python setup.py build
Run this now [n]? n
[root@testos ~]# python3 setup.py build
running build
running build_exe
copying /usr/local/lib/python3.3/site-packages/cx_Freeze-4.3.2-py3.3-linux-x86_64.egg/cx_Freeze/bases/Console -> build/exe.linux-x86_64-3.3/hhhh
writing zip file build/exe.linux-x86_64-3.3/library.zip
[root@testos ~]# cd build/exe.linux-x86_64-3.3
[root@testos exe.linux-x86_64-3.3]# ./hhhh
testos
################
192.1.1.10
需要特别注意的是,上面红色标注的部分,打包时不要指定,使用默认配置即可,否则可能最后打包的文件无法执行。
打包后,生成的可执行文件可以直接在本机运行,放到其它机器上也可以正常执行。当然,前期是,两者的运行环境就相同。
阅读(4015) | 评论(0) | 转发(0) |