我如何在Mac上安装PyQt5 ?

时间:2022-03-20 07:12:37

I am trying to install PyQt5 on my Mac but I do not know how to use it well. I have tried to install sip doing

我试着在我的Mac上安装PyQt5,但是我不知道如何使用它。我试着安装sip。

cd ~/Downloads/sip-4.17
python configure.py

which worked, and then I tried

哪个有用,然后我试了?

cd ~/Downloads/PyQt-gpl-5.5.1
python configure.py --qmake /Users/name/Qt/5.5/clang_64/bin/qmake

which returns an error that says

哪个返回一个错误?

Make sure you have a working sip on your PATH or use the --sip argument to explicitly specify a working sip.

确保在路径上有一个工作sip,或者使用——sip参数来显式指定工作sip。

How do I fix this error? Did I not install sip?

如何修正这个错误?我没有安装sip吗?

4 个解决方案

#1


12  

I'm kind of dodging the question, but the simplest way is to install Homebrew, and just run brew install pyqt or brew install pyqt5.

我是在避开这个问题,但最简单的方法是安装Homebrew,然后运行brew安装pyqt或brew安装pyqt5。

#2


12  

Meanwhile I have the ultimate way to install PyQt5 on macOS. Don't use Homebrew. It is great for installing Qt5, but for PyQt5 the best way to install it is using

同时我也有最终的办法在macOS上安装PyQt5。不要使用自制程序。这对于安装Qt5非常有用,但是对于PyQt5来说,安装它的最好方法是使用。

python3 -m pip install PyQt5

This works very quickly and uses universal Python Wheels:

这工作非常快,并且使用通用的Python车轮:

Collecting PyQt5
  Downloading PyQt5-5.9-5.9.1-cp35.cp36.cp37-abi3-macosx_10_6_intel.whl 
(82.2MB)
    100% |████████████████████████████████| 82.2MB 17kB/s 
Collecting sip<4.20,>=4.19.3 (from PyQt5)
  Downloading sip-4.19.3-cp36-cp36m-macosx_10_6_intel.whl (49kB)
    100% |████████████████████████████████| 51kB 1.2MB/s 
Installing collected packages: sip, PyQt5
Successfully installed PyQt5-5.9 sip-4.19.3

You see: Such a wheel is re-used for CPython 3.5, 3.6 and 3.7.

您可以看到:这样的*被重新用于CPython 3.5、3.6和3.7。

Remark: PySide2 is not as far, but we will build similar wheels when we have the first version ready.

备注:PySide2没有那么远,但是当我们准备好第一个版本时,我们将会构建类似的*。

Added on 2017/09/25: You can of course also use

2017/09/25添加:当然也可以使用。

pip3 install PyQt5

But at that time my pip/pip2/pip3 was a bit messy linked, so the first solution is rock solid and avoids confusion.

但是在那个时候,我的pip/pip2/pip3有点混乱,所以第一个解决方案是rock solid,避免混淆。

Also right is that you don't always get the lastest version of PyQt5 this way. But for getting started, the priority is to get results quickly and not the bleeding edge.

同样正确的是,你并不总是以这种方式获得最新版本的PyQt5。但是对于开始,首要的是要快速的得到结果而不是流血的边缘。

#3


1  

You need to install SIP first, which is not just running configure.py:

您需要首先安装SIP,它不只是运行configure.py:

>>> cd ~/Downloads/sip-4.17
>>> python configure.py
>>> make
>>> make install

Then you can install PyQt5:

然后你可以安装PyQt5:

>>> cd ~/Downloads/PyQt-gpl-5.5.1
>>> python configure.py --qmake /Users/name/Qt/5.5/clang_64/bin/qmake
>>> make
>>> make install

#4


0  

In ~/.pip/pip.log I discovered:

在~ / .pip /皮普。日志我发现:

Skipping https://pypi.python.org/packages/... (from https://pypi.python.org/simple/pyqt5/) because it is not compatible with this Python

Simply installed newwer version of Python 3 from official website and pip3 install PyQt5 finally worked.

从官方网站简单地安装了newwer版本的Python 3, pip3安装PyQt5最终成功了。

#1


12  

I'm kind of dodging the question, but the simplest way is to install Homebrew, and just run brew install pyqt or brew install pyqt5.

我是在避开这个问题,但最简单的方法是安装Homebrew,然后运行brew安装pyqt或brew安装pyqt5。

#2


12  

Meanwhile I have the ultimate way to install PyQt5 on macOS. Don't use Homebrew. It is great for installing Qt5, but for PyQt5 the best way to install it is using

同时我也有最终的办法在macOS上安装PyQt5。不要使用自制程序。这对于安装Qt5非常有用,但是对于PyQt5来说,安装它的最好方法是使用。

python3 -m pip install PyQt5

This works very quickly and uses universal Python Wheels:

这工作非常快,并且使用通用的Python车轮:

Collecting PyQt5
  Downloading PyQt5-5.9-5.9.1-cp35.cp36.cp37-abi3-macosx_10_6_intel.whl 
(82.2MB)
    100% |████████████████████████████████| 82.2MB 17kB/s 
Collecting sip<4.20,>=4.19.3 (from PyQt5)
  Downloading sip-4.19.3-cp36-cp36m-macosx_10_6_intel.whl (49kB)
    100% |████████████████████████████████| 51kB 1.2MB/s 
Installing collected packages: sip, PyQt5
Successfully installed PyQt5-5.9 sip-4.19.3

You see: Such a wheel is re-used for CPython 3.5, 3.6 and 3.7.

您可以看到:这样的*被重新用于CPython 3.5、3.6和3.7。

Remark: PySide2 is not as far, but we will build similar wheels when we have the first version ready.

备注:PySide2没有那么远,但是当我们准备好第一个版本时,我们将会构建类似的*。

Added on 2017/09/25: You can of course also use

2017/09/25添加:当然也可以使用。

pip3 install PyQt5

But at that time my pip/pip2/pip3 was a bit messy linked, so the first solution is rock solid and avoids confusion.

但是在那个时候,我的pip/pip2/pip3有点混乱,所以第一个解决方案是rock solid,避免混淆。

Also right is that you don't always get the lastest version of PyQt5 this way. But for getting started, the priority is to get results quickly and not the bleeding edge.

同样正确的是,你并不总是以这种方式获得最新版本的PyQt5。但是对于开始,首要的是要快速的得到结果而不是流血的边缘。

#3


1  

You need to install SIP first, which is not just running configure.py:

您需要首先安装SIP,它不只是运行configure.py:

>>> cd ~/Downloads/sip-4.17
>>> python configure.py
>>> make
>>> make install

Then you can install PyQt5:

然后你可以安装PyQt5:

>>> cd ~/Downloads/PyQt-gpl-5.5.1
>>> python configure.py --qmake /Users/name/Qt/5.5/clang_64/bin/qmake
>>> make
>>> make install

#4


0  

In ~/.pip/pip.log I discovered:

在~ / .pip /皮普。日志我发现:

Skipping https://pypi.python.org/packages/... (from https://pypi.python.org/simple/pyqt5/) because it is not compatible with this Python

Simply installed newwer version of Python 3 from official website and pip3 install PyQt5 finally worked.

从官方网站简单地安装了newwer版本的Python 3, pip3安装PyQt5最终成功了。