PyQt5安装错误(QtCore模块错误:无法创建C ++代码) [英] PyQt5 installation error (QtCore Module Error: Unable to create the C++ code)

查看:94
本文介绍了PyQt5安装错误(QtCore模块错误:无法创建C ++代码)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在PC上安装PyQt5,以便可以访问QtDesigner.

I'm trying to install PyQt5 on my PC to have access to QtDesigner.

我在安装过程中遇到以下错误:

I'm facing following error during the installation:

$ python3 configure.py --qmake=/usr/local/Cellar/qt/5.10.1/bin/qmake --sip=/usr/local/Cellar/sip/4.19.8_2/bin/sip
Querying qmake about your Qt installation...
Determining the details of your Qt installation...
This is the GPL version of PyQt 5.7 (licensed under the GNU General Public License) for Python 3.6.3 on darwin.

......
DBus v1 does not seem to be installed.
Qt v5.10.1 is being used.
The qmake executable is /usr/local/Cellar/qt/5.10.1/bin/qmake.
Qt is built as a shared library.
SIP 4.19.8 is being used.
The sip executable is /usr/local/Cellar/sip/4.19.8_2/bin/sip.
The PyQt5 Python package will be installed in
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages.
PyQt5 is being built with generated docstrings.
PyQt5 is being built with 'protected' redefined as 'public'.
The Designer plugin will be installed in
/usr/local/Cellar/qt/5.10.1/plugins/designer.
The qmlscene plugin will be installed in
/usr/local/Cellar/qt/5.10.1/plugins/PyQt5.
The PyQt5 PEP 484 stub files will be installed in
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5.
The PyQt5 .sip files will be installed in
/Library/Frameworks/Python.framework/Versions/3.6/share/sip/PyQt5.
pyuic5, pyrcc5 and pylupdate5 will be installed in
/Library/Frameworks/Python.framework/Versions/3.6/bin.
The interpreter used by pyuic5 is python3.6.
Generating the C++ source for the QtCore module...
Error: Unable to create the C++ code.

安装环境:

macOS Sierra(版本10.12.6)

macOS Sierra (version 10.12.6)

PyQt5 GPL 5.7

PyQt5 GPL 5.7

Qt 5.10

SIP 4.19.8

SIP 4.19.8

两个python版本,尝试了两个版本,但存在相同的问题.

Two python versions, tried with both versions but same problem.

$ python --version
Python 2.7.14

$ python3 --version
Python 3.6.3

按照以下自述说明进行安装:使用以下方法安装Qt:

Followed readme instructions for the installation: Installed Qt using following:

$ brew install qt
Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
 xcode-select --install

$ xcode-select --install
xcode-select: note: install requested for command line developer tools

$ brew install qt
Updating Homebrew...
==> Summary /usr/local/Cellar/qt/5.10.1: 9,375 files, 295.2MB

然后使用以下方法安装SIP:

Then installed SIP using following:

$brew install sip
==> Installing dependencies for sip: gdbm, openssl, readline, sqlite, xz, python, python@2
==> Summary /usr/local/Cellar/sip/4.19.8_2: 16 files, 1.1MB

更新:在配置命令中使用--verbose选项:

Update: Using --verbose option with configure command:

Generating the C++ source for the QtCore module...
/usr/local/Cellar/sip/4.19.8_2/bin/sip -w -f -t WS_MACX -t Qt_5_10_1 -B Qt_6_0_0 -P -o -y QtCore.pyi -c /Users/apple/Desktop/Python/PyQt5_gpl-5.7/QtCore -I sip -I /Users/apple/Desktop/Python/PyQt5_gpl-5.7/sip /Users/apple/Desktop/Python/PyQt5_gpl-5.7/sip/QtCore/QtCoremod.sip
sip: Deprecation warning: /Users/apple/Desktop/Python/PyQt5_gpl-5.7/sip/QtCore/QtCoremod.sip:23: %Module version numbers are deprecated and ignored
Error: Unable to create the C++ code.

请告知如何解决此错误.

Please advise how to solve this error.

感谢您的支持

推荐答案

设法解决该问题,该问题与使用的SIP版本有关.

Managed to sort it out, the issue was related to the used SIP version.

我使用了与PyQt5 5.7兼容的SIP版本,即SIP 4.18.1,并解决了该问题.

I used SIP version compatible with PyQt5 5.7 which is SIP 4.18.1 and the problem was solved.

下一步:

$make

我遇到了另一个问题:

error: 'WindowOkButtonHint' : is not a member of 'Qt'
error: 'WindowCancelButtonHint' : is not a member of 'Qt'

为解决此问题,我编辑了〜/QtCore/sipQtCoreQt.cpp文件,并删除了2条有问题的行.

To solve this I edited the ~/QtCore/sipQtCoreQt.cpp file and removed the 2 problematic lines.

http://patchwork.ozlabs.org/patch/720187/

这篇关于PyQt5安装错误(QtCore模块错误:无法创建C ++代码)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆