在MaOS上安装PyQT4时C++标准库的问题

2024-09-22 16:35:17 发布

您现在位置:Python中文网/ 问答频道 /正文

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

虽然只需一个命令pip install PyQt5就可以安装PyQt 5,但对于较旧的PyQt 4,这是不可能的,人们建议从源代码构建它

我已经按照建议在PyQt4 Download上安装了SIP

我还下载了PyQt4并将其解压。现在,当我运行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>
         ^~~~~~~~~~~

我没有Qt/QPoT的经验,但我猜这个旧版本的PyQT不会配置自己使用Mac OS的基于Clang的C++工具链。p>

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


Tags: theincludelibusrlocalnotframework建议
1条回答
网友
1楼 · 发布于 2024-09-22 16:35:17

这可能不是构建PyQt4的最佳/正确方法,但我已经构建了它,现在我的程序正在运行

以下解决方案要求安装Qt。我用它

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时,我得到了与之前相同的错误,但这次它来自生成的makefile。事实证明,将-mmacosx-version-min=10.5标志中的版本增加到-mmacosx-version-min=10.10(通过在所有生成的makefile中替换这一行)可以消除错误

(我对此的解释是,MaOSKSDK的后期版本不使用GCC的旧C++标准库,而是使用他们的新CLAN C++工具链的C++库)

之后,在运行基于PyQt4的应用程序时,我点击:

ImportError: No module named sip

找到了解决方案here:我必须使用附加标志重建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

相关问题 更多 >