1. 程式人生 > >PyQt在Windows XP上的編譯

PyQt在Windows XP上的編譯

編譯前, 須安裝mingw, python, qt(要編譯的話, 請參考這裡).

編譯並安裝sip

1.        下載並解壓sip
2.        開啟cmd, 在sip的根路徑下輸入如下命令:
       > python configure.py -p win32-g++
       > mingw32-make
       > mingw32-make install

3.        上步結束後, 在Python的路徑下應該有:

           C:\Python25\include\sip.h
           C:\Python25\Lib\site-packages\sip.pyd
           C:\Python25\Lib\site-packages\sipconfig.py
           C:\Python25\Lib\site-packages\sipconfig.pyc
           C:\Python25\Lib\site-packages\sipdistutils.py
           C:\Python25\sip.exe

編譯並安裝PyQt

1.        下載並解壓pyqt
2.        開啟cmd, 在pyqt的根路徑下輸入如下命令:
       > python configure.py -w
       > mingw32-make
       > mingw32-make install
3.        上步結束後, 在Python的路徑下應該有:
           C:/Python25
           C:/Python25/Lib/site-packages
           C:/Python25/Lib/site-packages/PyQt4
           C:/Python25/Lib/site-packages/PyQt4/pyqtconfig.py
           C:/Python25/Lib/site-packages/PyQt4/Qt.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtAssistant.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtCore.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtDesigner.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtGui.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtNetwork.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtOpenGL.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtScript.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtSql.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtSvg.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtTest.pyd
           C:/Python25/Lib/site-packages/PyQt4/QtXml.pyd
           C:/Python25/Lib/site-packages/PyQt4/uic
           C:/Python25/Lib/site-packages/PyQt4/uic/Compiler
           C:/Python25/Lib/site-packages/PyQt4/uic/Loader
           C:/Python25/Lib/site-packages/PyQt4/uic/widget-plugins
           C:/Python25/Lib/site-packages/sip.pyd
           C:/Python25/Lib/site-packages/sipconfig.py
           C:/Python25/Lib/site-packages/sipconfig.pyc
           C:/Python25/pylupdate4.exe
           C:/Python25/pyrcc4.exe
           C:/Python25/pyuic4.bat
           C:/Python25/sip
           C:/Python25/sip/PyQt4
           C:/Python25/sip/PyQt4/Qt
           C:/Python25/sip/PyQt4/Qt/Qtmod.sip
           C:/Python25/sip/PyQt4/QtAssistant
           C:/Python25/sip/PyQt4/QtCore
           C:/Python25/sip/PyQt4/QtDesigner
           C:/Python25/sip/PyQt4/QtGui
           C:/Python25/sip/PyQt4/QtNetwork
           C:/Python25/sip/PyQt4/QtOpenGL
           C:/Python25/sip/PyQt4/QtScript
           C:/Python25/sip/PyQt4/QtSql
           C:/Python25/sip/PyQt4/QtSvg
           C:/Python25/sip/PyQt4/QtTest

           C:/Python25/sip/PyQt4/QtXml

安裝結束, 測試安裝是否成功:
    > python
    Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
    win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from PyQt4.Qt import *
    >>> from sip import *
    >>> print SIP_VERSION_STR, QT_VERSION_STR, PYQT_VERSION_STR
    4.13.3 4.6.4 4.9.4
    >>>