我正在尝试在我的 Mac 上安装 PyQt,以便我能够安装 Python Ghost。我已经安装了 Qt 和 SIP。我已经下载了 PyQt,但是当我运行时
python configure-ng.py
我遇到了以下错误:
Error: Use the --qmake argument to explicitly specify a working Qt qmake.
有什么建议吗?
由于您使用的是Mac电脑,我建议使用Homebrew。这在我之前的一天成功了,但要花费很长时间完成:
brew install pyqt
vext.pyqt4
和 vext.pyqt5
包,可以让虚拟环境访问全局安装的 pyqt 库。使用 Riverbank 提供的二进制安装程序对我来说非常完美。 - Georg Schöllyconfigure-ng.py
需要同时使用qmake
和sip
来配置构建过程。
这个错误信息意味着configure-ng.py
无法找到qmake
可执行文件。您需要指定其位置,类似于这样:
$ python configure-ng.py --qmake=/path/to/qmake
qmake
的位置取决于1)您如何安装它 2)您正在使用的操作系统。
对于Mac OS,在我的情况下,较为简便的方法是使用Homebrew安装sip
和qmake
。
$ brew install sip
$ brew install qt
brew
将它们安装在目录:/usr/local/Cellar/
然后,运行configure-ng.py
并指定两个位置:
$ python configure-ng.py --qmake=/usr/local/Cellar/qt/VERSION/bin/qmake --sip=/usr/local/Cellar/sip/VERSION/bin/sip
$ make
make
需要一段时间(在我的情况下大约需要20分钟)。
最后,安装:
$ make install
make
命令可能需要管理员权限$ sudo make
#!/usr/bin/env python3
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QWidget
from PyQt5.QtCore import Qt
class Example(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setFixedSize(200, 100)
self.setWindowTitle('Example')
label = QLabel('Hello')
layout = QVBoxLayout()
layout.addWidget(label)
layout.setAlignment(Qt.AlignCenter)
self.setLayout(layout)
if __name__ == '__main__':
import sys
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
ex = Example()
ex.show()
sys.exit(app.exec_())
--qmake path/to/qt/bin/qmake
。 - ekhumoropython configure.py --qmake ~/Qt/5.2.1/clang_64/bin/qmake
- GP89