平台:
[yorks@localhost ~]$ cat /proc/version
Linux version 2.6.27.7-32 (root@everestbuilder.redflag-linux.com) (gcc version 4.3.2 20080905 (Everest 4.3.2-6) (GCC) ) #1 SMP Fri Dec 12 14:39:06 CST 2008
默认安装了python
[yorks@localhost ~]$ python
Python 2.5.4 (r254:67916, Dec 27 2008, 18:46:14)
[GCC 4.3.2 20080905 (Everest 4.3.2-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
并且安装了python的开发库:
[yorks@localhost ~]$ rpm -qa |grep python-dev
dbus-python-devel-0.83.0-4
python-devel-2.5.4-1安装cx_Freeze:
1、下载源码包:
[yorks@localhost ~]$ wget -c
2、解压,编译,安装:
[yorks@localhost ~]$ tar xvf cx_Freeze-4.1.tar.gz
[yorks@localhost ~]$ cd cx_Freeze-4.1
[yorks@localhost cx_Freeze-4.1]$ ls
build cx_Freeze doc initscripts MANIFEST.in README.txt setup.py
cxfreeze cx_Freeze.egg-info HISTORY.txt LICENSE.txt PKG-INFO samples source
[yorks@localhost cx_Freeze-4.1]$ more README.txt
Please see cx_Freeze.html for documentation on how to use cx_Freeze.
To build:
python setup.py build
python setup.py install
On Windows I have used the MinGW compiler ()
python setup.py build --compiler=mingw32
python setup.py build --compiler=mingw32 install
[yorks@localhost cx_Freeze-4.1]$ python setup.py build
.............
很多东东,过后
[yorks@localhost cx_Freeze-4.1]$ su
密码:
[root@localhost cx_Freeze-4.1]# python setup.py install
.........
很多东东,过后,安装成功。
[yorks@localhost cx_Freeze-4.1]$ cxfreeze --v
cxfreeze 4.1
Copyright (c) 2007-2009 Anthony Tuininga. All rights reserved.
Copyright (c) 2001-2006 Computronix Corporation. All rights reserved.
表示安装成功。
======================================================
使用:
[yorks@localhost cx_Freeze-4.1]$ cd /home/yorks/work/pypassport
[yorks@localhost pypassport]$ cxfreeze login.py
creating directory /home/yorks/work/pypassport/dist
coyping /usr/lib/python2.5/site-packages/cx_Freeze/bases/Console -> /home/yorks/work/pypassport/dist/login
coyping /usr/lib/libpython2.5.so.1.0 -> /home/yorks/work/pypassport/dist/libpython2.5.so.1.0
writing zip file /home/yorks/work/pypassport/dist/login
Name File
---- ----
m StringIO
m Ui_f_about Ui_f_about.py
.........................
一大堆东西后。。。
[yorks@localhost pypassport]$ cd dist/
[yorks@localhost dist]$ ll -h
总计 14M
-rw-rw-r-- 1 yorks yorks 78K 08-03 15:16 arraymodule.so
-rw-rw-r-- 1 yorks yorks 45K 08-03 15:16 binascii.so
-rw-rw-r-- 1 yorks yorks 7.4K 08-03 15:16 _bisect.so
-rw-rw-r-- 1 yorks yorks 28K 08-03 15:16 bz2.so
-rw-rw-r-- 1 yorks yorks 146K 08-03 15:16 _codecs_cn.so
-rw-rw-r-- 1 yorks yorks 153K 08-03 15:16 _codecs_hk.so
-rw-rw-r-- 1 yorks yorks 48K 08-03 15:16 _codecs_iso2022.so
-rw-rw-r-- 1 yorks yorks 246K 08-03 15:16 _codecs_jp.so
-rw-rw-r-- 1 yorks yorks 136K 08-03 15:16 _codecs_kr.so
-rw-rw-r-- 1 yorks yorks 109K 08-03 15:16 _codecs_tw.so
-rw-rw-r-- 1 yorks yorks 54K 08-03 15:16 collectionsmodule.so
-rw-rw-r-- 1 yorks yorks 41K 08-03 15:16 cStringIO.so
-rw-rw-r-- 1 yorks yorks 59K 08-03 15:16 datetime.so
-rw-rw-r-- 1 yorks yorks 29K 08-03 15:16 fcntlmodule.so
-rw-rw-r-- 1 yorks yorks 12K 08-03 15:16 _hashlib.so
-rw-rw-r-- 1 yorks yorks 72K 08-03 15:16 itertoolsmodule.so
-rw-rw-r-- 1 yorks yorks 3.3M 08-03 15:16 libpython2.5.so.1.0
-rw-rw-r-- 1 yorks yorks 35K 08-03 15:16 _localemodule.so
-rwxr-xr-x 1 yorks yorks 1.1M 08-03 15:16
login-rw-rw-r-- 1 yorks yorks 32K 08-03 15:16 mathmodule.so
-rw-rw-r-- 1 yorks yorks 29K 08-03 15:16 _md5module.so
-rw-rw-r-- 1 yorks yorks 63K 08-03 15:16 _multibytecodecmodule.so
-rw-rw-r-- 1 yorks yorks 55K 08-03 15:16 operator.so
-rw-rw-r-- 1 yorks yorks 93K 08-03 15:16 pyexpat.so
-rw-rw-r-- 1 yorks yorks 6.1M 08-03 15:16 qt.so
-rw-rw-r-- 1 yorks yorks 27K 08-03 15:16 _randommodule.so
-rw-rw-r-- 1 yorks yorks 28K 08-03 15:16 _shamodule.so
-rw-rw-r-- 1 yorks yorks 76K 08-03 15:16 sip.so
-rw-rw-r-- 1 yorks yorks 113K 08-03 15:16 _socketmodule.so
-rw-rw-r-- 1 yorks yorks 60K 08-03 15:16 _ssl.so
-rw-rw-r-- 1 yorks yorks 51K 08-03 15:16 stropmodule.so
-rw-rw-r-- 1 yorks yorks 65K 08-03 15:16 _struct.so
-rw-rw-r-- 1 yorks yorks 30K 08-03 15:16 termios.so
-rw-rw-r-- 1 yorks yorks 37K 08-03 15:16 timemodule.so
-rw-rw-r-- 1 yorks yorks 493K 08-03 15:16 unicodedata.so
-rw-rw-r-- 1 yorks yorks 16K 08-03 15:16 _weakref.so
-rw-rw-r-- 1 yorks yorks 46K 08-03 15:16 zlibmodule.so
运行看看:
[yorks@localhost dist]$ ./login
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/cx_Freeze/initscripts/Console.py", line 27, in
exec code in m.__dict__
File "login.py", line 12, in
ImportError: No module named sip
出错了..
后来经过google后, 发现cxfreeze 没有加入sip,这个qt一定要的,因为我在.py文件里面没有写
import sip 所以cxfreeze也没有加入sip...所以运行缺少sip...
解决:
修改login.py 加入import sip .
重新打包.
[yorks@localhost pypassport]$ rm -rf dist
[yorks@localhost pypassport]$ cxfreeze login.py
再运行看看。。
[yorks@localhost pypassport]$ cd dist
[yorks@localhost dist]$ ./login
弹出我的上网验证登录界面了,呵呵。
上图: