cx_freeze安装使用

在windows下 安装比较方便又专门的安装包

然后cmd 进入 c:python33Scripts

>cxfreeze E:main.py --target-dir E:

前面是源文件,如果有多个文件的话就是主程序在的文件,最后一个是生成程序的目录

在linux下 下载cx_freeze的源码后解压,

进入cx_Freeze-4.3.4

输入 sudo python3 setup.py build  # 因为我用的是python3.4版本所以用python3 而且需要先安装python3.4的dev

这编译出错

build/temp.linux-x86_64-2.7/source/bases/Console.o:在函数‘GetImporterHelper’中:
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Common.c:211:对‘PyObject_CallMethod’未定义的引用
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Common.c:215:对‘PyErr_Clear’未定义的引用
build/temp.linux-x86_64-2.7/source/bases/Console.o:在函数‘GetDirName’中:
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Common.c:66:对‘PyString_FromStringAndSize’未定义的引用
build/temp.linux-x86_64-2.7/source/bases/Console.o:在函数‘FatalError’中:
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Console.c:24:对‘PyErr_Print’未定义的引用
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Console.c:25:对‘Py_FatalError’未定义的引用
build/temp.linux-x86_64-2.7/source/bases/Console.o:在函数‘SetExecutableName’中:
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Common.c:93:对‘PyString_FromString’未定义的引用
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Common.c:115:对‘PyString_FromStringAndSize’未定义的引用
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Common.c:136:对‘PyString_FromString’未定义的引用
build/temp.linux-x86_64-2.7/source/bases/Console.o:在函数‘FatalError’中:
/home/bill/Downloads/cx_Freeze-4.3.3/source/bases/Console.c:24:对‘PyErr_Print’未定义的引用

。。。。

查了一下 网上有修改setup.py  将其中的if not vars.get("Py_ENABLE_SHARED", 0): 修改成 if True:

就可以了

最后 sudo python3 setup.py install

完成

用法 是 终端下 cxfreeze ~main.py --target-dir ~

原文地址:https://www.cnblogs.com/yemeng/p/5132053.html