无法在OS X 10.10.5 Yosemite中安装PyQt4与Python 3.6



今天我尝试安装需要vtk的mayavi。我终于安装了vtk并可导入,但在这个过程中破坏了我的Python 3.4环境。无论如何,我是时候换到3.6了,所以这不是一个大问题,但最大的问题是现在无法安装PyQt4。

我让Qt(5.7.1)和SIP(4.19)只遇到了一点麻烦,但我在使用PyQt4时遇到了障碍。我尝试过brew install pyqt,也尝试过从源代码构建它。在这两种情况下,结果都是:

Determining the layout of your Qt installation...
/usr/local/opt/qt5/bin/qmake -spec macx-g++ -o qtdirs.mk qtdirs.pro
make -f qtdirs.mk
/Applications/Xcode.app/Contents/Developer/usr/bin/g++ -c -pipe -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.8 -O2-std=gnu++11 -Wall -W -fPIC -DQT_NO_DEBUG -DQT_CORE_LIB -I. -I/usr/local/Cellar/qt5/5.7.1_1/lib/QtCore.framework/Headers -I. -I/usr/local/Cellar/qt5/5.7.1_1/mkspecs/macx-g++ -F/usr/local/Cellar/qt5/5.7.1_1/lib -o qtdirs.o qtdirs.cpp
In file included from qtdirs.cpp:1:
In file included from /usr/local/Cellar/qt5/5.7.1_1/lib/QtCore.framework/Headers/QCoreApplication:1:
In file included from /usr/local/Cellar/qt5/5.7.1_1/lib/QtCore.framework/Headers/qcoreapplication.h:43:
In file included from /usr/local/Cellar/qt5/5.7.1_1/lib/QtCore.framework/Headers/qglobal.h:1145:
In file included from /usr/local/Cellar/qt5/5.7.1_1/lib/QtCore.framework/Headers/qatomic.h:46:
/usr/local/Cellar/qt5/5.7.1_1/lib/QtCore.framework/Headers/qbasicatomic.h:61:4: error: "Qt requires C++11 support"
#  error "Qt requires C++11 support"
^

作为回应,我尝试了export CXXFLAGS=-std=c++11和(分别和一起)export CPPFLAGS=-std=c++11,但没有帮助。我还尝试将以下内容添加到qtdirs.pro文件中,但没有任何区别:

QMAKE_LFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -stdlib=libc++
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -mmacosx-version-min=10.7
QMAKE_LFLAGS += -mmacosx-version-min=10.7

下一步是什么?

修复起来非常简单。我下载并安装了qt-opensource-mac-4.8.7.dmg,因此/usr/bin中的qmake适用于Qt 4.8.7,然后简单地进入PyQt4_gpl_mac-4.12并键入python configure.py && make即可成功完成。

最新更新