在windows平台上使用mingw编译PYQT5

1、准备工作

下载 pyqt5:https://sourceforge.net/projects/pyqt/files/PyQt5/  下载zip文件

下载 sip :点击打开链接

下载 python:点击打开链接

下载 mingw:点击打开链接

下载 qt5:http://download.qt.io/archive/qt/  下载mingw版本

qtcreator: http://download.qt.io/official_releases/qtcreator

2、设置环境变量

解压 pyqt5 到指定目录,安装qt5到指定目录,安装python,安装mingw

设置python 、mingw、qt5到系统path环境变量

因为编译时会报hypot has not been declared的错误,所以要修改下python代码
打开python 根目录,修改include文件夹下面的python.h文件
把include“math.h”放在include“Python”之前(还是会搞了编辑源代码的方法)。
修改Python.h
在开头加上math.h
#ifndef Py_PYTHON_H
#define Py_PYTHON_H

#include "math.h"

3、编译


打开CMD命令行

首先编译sip

进入sip根目录,执行下面命令:

python configure.py -p win32-g++
make
make install

然后编译PyQt

进入pyqt根目录,执行下面的命令:

python configure.py --spec win32-g++ --confirm-license

或者

python configure.py --spec win32-g++ --confirm-license --disable=QtPositioning --disable=QtNfc --disable=QtBluetooth --no-designer-plugin --no-qml-plugin

make
make install

之后就可以在Lib\site-packages\PyQt5看到你编译好的qt5的pyd绑定


部分参考:

http://python.6.x6.nabble.com/Building-PyQt-on-Windows-problems-generating-the-C-code-td5212692.html

https://zhuanlan.zhihu.com/p/20528827

http://blog.csdn.net/sqn614/article/details/68946756


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章