在ubuntu上安装cx_freeze

时间:2016-05-13 21:32:10

标签: python linux cx-freeze

我安装了python2.7和python 3.4m的kubuntu 15.10 如果我用sudo apt-get cx_freeze安装cxfreeze它安装没有问题,但问题是当我编译我的python模块时编译为python2.7而不是python 3 所以我想从源代码构建cx_freeze,当我运行sudo python3 setup.py build

时我遇到了这个错误

这是错误

adding base module named weakref 
running build
running build_py
running build_ext
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict
prototypes -g -fstack-protector-strong -Wformat -Werror=format
security -D_FORTIFY_SOURCE=2 -fPIC -Ibuild/temp.linux-x86_64-3.4
I/usr/include/python3.4m -c source/bases/Console.c -o
build/temp.linux-x86_64-3.4/source/bases/Console.o
x86_64-linux-gnu-gcc -pthread build/temp.linux-x86_64
3.4/source/bases/Console.o -L/usr/lib/python3.4/config-3.4m-x86_64
linux-gnu -lpython3.4 -o build/lib.linux-x86_64
3.4/cx_Freeze/bases/Console -Xlinker -export-dynamic -Wl,-O1 -Wl,
Bsymbolic-functions -lpthread -ldl -lutil -lm -lrt -lexpat -L/usr/lib
-lz -lexpat -s
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1'

2 个答案:

答案 0 :(得分:0)

我完全拥有same problem。正如在this中所建议的那样,您只需要先安装依赖项:

pip3 install zlib1g-dev

然后sudo python3 setup.py build

答案 1 :(得分:0)

安装zlib1g-devsudo apt install zlib1g-dev

然后为python安装cx_freezepip install cx_freeze

我已经在Ubuntu 18.04和Python 3.6上尝试过并且可以正常工作。