Skip to main content
 首页 » 编程设计

python之使用 MinGW(PyQt4.11、Qt4.8.6)在 Windows7 上构建 Qscintilla2 python 绑定(bind)

2025年05月04日10JustinYoung

我已经尝试解决这个问题大约 3 天了,我终于觉得我需要通过创建自己的问题来寻求帮助。
我安装了 Windows 7x64 和 Qt4.8.6。
我需要安装并运行带有 PyQt 和 Qscintilla2 的 Python。
现在我将描述我最后的行动。我按照随附的软件包说明进行了所有操作。
1) 从官方网站安装Python2.7.9 32bit。
2) 从 here 下载 SIP (开发快照),然后:
configure.py —platform win32-g++ mingw32-make mingw32-make install
3) 从 here 下载 PyQt (不是安装程序而是开发快照,因为我需要使用 MinGW 和安装程序生成 MSVC 版本进行构建),然后:
configure-ng.py -spec win32-g++ mingw32-make mingw32-make install
在这些步骤之后,我在我的项目中测试了 PyQt - 一切正常。 然后我开始尝试安装Qsnitilla2。
4) 从 here 下载 Qsnitilla2 (开发快照),然后:
a) 在 Qt4Qt5 文件夹中:
qmake qscintilla.pro -spec win32-g++ mingw32-make mingw32-make install
如我所见,这已在 Qt4.8.6 中安装了 Qsnitilla2;
b) 在 Python 文件夹中(F..ing Python bindngs,请原谅我的法语):
config.py —spec win32-g++ mingw32-make
在此之后我得到 ld.exe 错误(链接错误):

然后,在做一些研究之后,我手动编辑了我的 Makefile.Release(通过将 -lpython27 添加到 LIBS 参数):
LIBS = -L"c:\Qt-mingw\4.8.6\lib" -LC:\Python27\libs -LC:\Qt-mingw\4.8.6\lib -lqscintilla2 -lQtGui4 -lQtCore4 <strong>-lpython27</strong>
在此之后,我的mingw32-make成功完成。所以:
mingw32-make install
这已经安装了 Qscintilla2 Python 绑定(bind)。 现在我可以在 Eclipse 中看到 Qsci autocomlplete。 所以我试过了:
from PyQt4.Qsci import QsciScintilla
我在回溯中得到了这个:
from PyQt4.Qsci import QsciScintilla ImportError: DLL load failed: Не найден указанный модуль <em>(Translation: The specified module could not be found)</em>

我已经用 Riverbank 网站上的 dev snapshot 和 src packages 试过了。还有 MinGW 4.8.1 和 MinGW-w64 4.8.4。我不能在 4.8 版本 上使用 MinGW-w64 因为我需要 boost-1.55 而且它只支持 MinGW 4.8.

我不知道现在该怎么办,但我真的很想在我的项目中使用 Scintilla。所以我将非常感谢任何建议。

请您参考如下方法:

您是否尝试过直接从控制台加载 QsciScintilla?我的意思是你需要进入QScintilla所在的目录(这意味着当前文件夹是默认文件夹),然后尝试运行命令“from PyQt4.Qsci import QsciScintilla”,如果这个加载模块失败仍然发生,这可能意味着你需要QScintilla 依赖的额外动态,你需要使用 dll dependency找出是否缺少其他一些库,然后将缺少的库放入 QsciScintilla 的同一文件夹中。