如何检查Mac上是否正确安装了PyQt5?

时间:2021-09-01 20:58:04

I've followed the instructions on:

我按照说明操作:

http://danmarner.com/2014/04/23/Installing-PyQt5-with-Python-3-On-OS-X.html

to first install SIP according to the instructions found at:

首先根据以下指令安装SIP:

http://pyqt.sourceforge.net/Docs/sip4/installation.html

and then PyQt5 by following the instructions found here:

然后按照此处的说明操作PyQt5:

http://pyqt.sourceforge.net/Docs/PyQt5/installation.html

and then brew install qt5

然后brew安装qt5

but when I run the first example PyQt-gpl-5.3.2/examples/tutorials/addressbook/part1.py it fails with the following:

但是当我运行第一个示例PyQt-gpl-5.3.2 / examples / tutorials / addressbook / part1.py时,它失败并带有以下内容:

Traceback (most recent call last):
  File "examples/tutorials/addressbook/part1.py", line 45, in <module>
    from PyQt5.QtCore import Qt
ImportError: No module named PyQt5.QtCore

I'm running Mavericks 10.9.5 and Python 2.7.5

我正在运行Mavericks 10.9.5和Python 2.7.5

It doesn't seem like it's installed correctly, or if it is python can't find it. I'm not sure how to proceed so any suggestions are much appreciated!

它似乎没有正确安装,或者如果它是python无法找到它。我不知道如何继续,所以任何建议都非常感谢!

2 个解决方案

#1


1  

The issue was resolved by adding /usr/local/lib/python2.7/site-packages to PYTHONPATH. Thanks to the comments found here:

通过将/usr/local/lib/python2.7/site-packages添加到PYTHONPATH来解决该问题。感谢此处的评论:

https://*.com/a/13103438/1729686

and to @Kash and @qqvc for the suggestions!

和@Kash和@qqvc的建议!

#2


1  

if you used brew, you can add into .bashrc

如果您使用brew,则可以添加到.bashrc中

export PYTHONPATH=$(brew --prefix)/lib/python3.6/site-packages:$PYTHONPATH

(edit python3.6 to your python version).

(将python3.6编辑为python版本)。

And next, reload bash and run

然后,重新加载bash并运行

echo $PYTHONPATH

if response not null, thats ok

如果响应不为null,那没关系

#1


1  

The issue was resolved by adding /usr/local/lib/python2.7/site-packages to PYTHONPATH. Thanks to the comments found here:

通过将/usr/local/lib/python2.7/site-packages添加到PYTHONPATH来解决该问题。感谢此处的评论:

https://*.com/a/13103438/1729686

and to @Kash and @qqvc for the suggestions!

和@Kash和@qqvc的建议!

#2


1  

if you used brew, you can add into .bashrc

如果您使用brew,则可以添加到.bashrc中

export PYTHONPATH=$(brew --prefix)/lib/python3.6/site-packages:$PYTHONPATH

(edit python3.6 to your python version).

(将python3.6编辑为python版本)。

And next, reload bash and run

然后,重新加载bash并运行

echo $PYTHONPATH

if response not null, thats ok

如果响应不为null,那没关系