在macOS上安装PyQt4时,遇到C++标准库的问题。

问题描述 投票:0回答:1

我正在尝试构建PyQt 4,因为我需要运行的程序使用了它。

虽然安装PyQt 5很简单,只需要一个命令就可以了。pip install PyQt5在旧的PyQt 4上是不可能的,人们建议从源头开始构建。

我已经按照建议安装了SIP PyQt4下载.

我也下载了PyQt 4并解压缩。现在当我运行 python configure.py --verbose,我得到

Stanislaw@home:PyQt4_gpl_mac-4.12.3 (master)*$ python configure.py --verbose
Determining the layout of your Qt installation...
/usr/local/bin/qmake -spec macx-g++ -o qtdirs.mk qtdirs.pro
make -f qtdirs.mk
g++ -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -Wall -W -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/local/etc/qt4/mkspecs/macx-g++ -I. -I/usr/local/Cellar/qt@4/4.8.7_6/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt@4/4.8.7_6/lib/QtCore.framework/Versions/4/Headers -I/usr/local/include -I. -F/usr/local/lib -o qtdirs.o qtdirs.cpp
warning: include path for stdlibc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
...
/usr/local/lib/QtCore.framework/Headers/qglobal.h:68:10: fatal error: 'algorithm' file not found
#include <algorithm>
         ^~~~~~~~~~~

我没有任何使用Qtqmake的经验,但我猜测这个老版本的PyQt没有配置自己正确使用macOS的基于Clang的C++工具链。

我将继续挖掘,但我也想知道是否存在解决这个问题的微不足道的方法。

python macos pyqt4
1个回答
0
投票

这可能不是构建PyQt 4的正确方法,但我已经构建好了,现在我的程序正在运行。

下面的解决方案需要安装Qt。I 安装

brew install cartr/qt4/pyqt@4

现在是PyQt部分。

PyQt的安装包括3个步骤。

 python configure.py
 make
 make install

要使 python configure.py 步工作,我不得不改变这个在 configure.py 文件。

-qt_macx_spec = 'macx-g++'
+qt_macx_spec = 'macx-llvm'

在第二步,当运行 make 我得到了和以前一样的错误,但这次是来自生成的Makefiles。原来,在 -mmacosx-version-min=10.5 旗帜鲜明 -mmacosx-version-min=10.10 (在所有生成的Makefile中替换这一行)使错误消失了。

(我对这一点的解释是,以后版本的macOS SDK不使用GCC的旧C++标准库,而是使用他们新的Clang C++工具链的C++库。)

之后,当运行我的基于PyQt4的应用程序时,我打。

ImportError: No module named sip

找到了解决方案 此处: 我不得不用额外的标志重建SIP。

cd sip-4.19.22
# `make clean` is important otherwise rebuilding will not work
# your program might complain with
# "ValueError: PyCapsule_GetPointer called with incorrect name"
make clean 
python configure.py --sip-module PyQt4.sip
© www.soinside.com 2019 - 2024. All rights reserved.