【问题标题】:PyQt5 installation error (QtCore Module Error: Unable to create the C++ code)PyQt5安装错误(QtCore Module Error: Unable to create the C++ code)
【发布时间】:2018-09-10 03:29:22
【问题描述】:

我正在尝试在我的 PC 上安装 PyQt5 以访问 QtDesigner。

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

$ 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)

PyQt5 GPL 5.7

Qt 5.10

SIP 4.19.8

两个python版本,两个版本都试过了,但同样的问题。

$ python --version
Python 2.7.14

$ python3 --version
Python 3.6.3

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

$ 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:

$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 选项:

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.

请告知如何解决此错误。

感谢您的支持

【问题讨论】:

    标签: python macos pyqt pyqt5 python-sip


    【解决方案1】:

    已解决,问题与使用的 SIP 版本有关。

    我使用了兼容 PyQt5 5.7 的 SIP 版本,即 SIP 4.18.1,问题解决了。

    下一步:

    $make
    

    我遇到了另一个问题:

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

    为了解决这个问题,我编辑了 ~/QtCore/sipQtCoreQt.cpp 文件并删除了 2 个有问题的行。

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

    【讨论】:

    • 感谢 SIP 版本说明,在我的情况下设法忽略了这一点。
    • 对于 PyQt5 5.15.12,pip install sip==5.5.0 似乎对我有用。
    【解决方案2】:

    我听从了上面@armyoung 的建议,结果成功了。 :)

    修改configure_ng.py的确切方法是找到并删除(或注释掉)这两行:

    argv.append('-B') 
    argv.append('Qt_5_0_0') 
    

    【讨论】:

      【解决方案3】:

      同样的问题!

      第一:

      sudo python configure_ng.py --verbose

      --verbose args 查看更多详情

      然后它显示:

      sip -B 不支持

      所以我修改了configure_ng.py

      【讨论】:

      • 请在您的答案中添加更多信息,例如您如何修改configure_ng.py。考虑到 OP 作者已经回答了这个问题,这是一个非常低质量的答案。
      猜你喜欢
      • 1970-01-01
      • 2017-09-30
      • 2022-12-26
      • 2022-08-09
      • 2018-12-13
      • 2020-05-13
      • 1970-01-01
      • 2015-01-04
      • 2018-07-30
      相关资源
      最近更新 更多