第一次完整的編譯一個工程。哈哈 記錄一下
準備環境
我的環境是win7 x64, python2.7.5 x64的。 python 3.x的我沒試過,有需要的朋友可以試一下。
-
安裝python2.7.5 x64
確保將安裝路徑加入到Path中
-
PyQt4
啊 我的環境是win的 當然要下win版 (PyQt4-4.10.3-gpl-Py2.7-Qt4.8.5-x64.exe)
可能有的同學跟我一樣糾結安裝到哪里。我就直接安裝在python的目錄中了。
安裝完了之后進python, import PyQt4 試試可不可以。
如果出現"ImportError: DLL load failed: %1 不是有效的 Win32 應用程序",說明與Python的bit不同。32位裝32位的 64裝64的哦。
-
cxFreeze
x64的cx_Freeze-4.3.2.win-amd64-py2.7.msi
-
py2exe
x64的x64的(py2exe-0.6.9.win64-py2.7.amd64.exe)
-
inno
unicode的安裝包 (isetup-5.5.4-unicode.exe)
安裝完之后需要你手動將安裝路徑添加到PATH中。
打開CMD來輸入iscc測試一下。
編譯
`python setup.py`
祝大家都編譯成功哦
編譯錯誤
`error: can't copy 'C:\Python27\Lib\site-packages\PyQt4\plugins\phonon_backend\phonon_ds94.dll': doesn't exist or not a regular file`
啊 我的python路徑明明不在這里了。估計是code寫錯了。
在setup.py中,370+行是這么寫的
dist.data_files += [('phonon_backend', ['C:\Python27\Lib\site-packages\PyQt4\plugins\phonon_backend\phonon_ds94.dll']),('imageplugins', ['c:\Python27\lib\site-packages\PyQt4\plugins\imageformats\qgif4.dll','c:\Python27\lib\site-packages\PyQt4\plugins\imageformats\qjpeg4.dll','c:\Python27\lib\site-packages\PyQt4\plugins\imageformats\qsvg4.dll','c:\Python27\lib\site-packages\PyQt4\plugins\imageformats\qico4.dll',])]
改之:
python_lib_path = os.path.dirname(PyQt4.__file__)dist.data_files += [('phonon_backend', [os.path.join(python_lib_path, 'plugins\phonon_backend\phonon_ds94.dll')]),('imageplugins', [os.path.join(python_lib_path, 'plugins\imageformats\qgif4.dll'),os.path.join(python_lib_path, 'plugins\imageformats\qjpeg4.dll'),os.path.join(python_lib_path, 'plugins\imageformats\qsvg4.dll'),os.path.join(python_lib_path, 'plugins\imageformats\qico4.dll'),])