如何为 Python 2.7 安装 PyQT4?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36615952/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:07:47  来源:igfitidea点击:

How can i install PyQT4 for Python 2.7?

pythonmacosqtpython-2.7pyqt

提问by ShellRox

I am trying to install PyQT4 on Python 2.7.9, I am on Mac OS X, so i tried installing it via Homebrew and Macports, unfortunately non of them seemed to work.

我正在尝试在 Python 2.7.9 上安装 PyQT4,我在 Mac OS X 上,所以我尝试通过 Homebrew 和 Macports 安装它,不幸的是它们似乎都不起作用。

This is what i tried:

这是我试过的:

brew install python qt pyqt pyside pyside-tools

also tried:

也试过:

brew install PyQT4

On Macports:

在 Macports 上:

sudo port install py27-pyqt4

No matter what I did, I was getting this error:

无论我做什么,我都收到此错误:

>>>> import PyQT4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PyQT4

What can be the problem? Do i need to set env path for PyQT?

可能是什么问题?我需要为 PyQT 设置 env 路径吗?

回答by ShellRox

Found out solution:

找到解决办法:

I installed PyQtX package, (PyQt binary for Mac OS X) from here.

我从这里安装了 PyQtX 包(Mac OS X 的 PyQt 二进制文件)。

and then specified PYTHONPATHwith this:

然后PYTHONPATH用这个指定:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

After typing in import PyQt4it worked without any problems. (Case Sensitive)

输入后import PyQt4它工作没有任何问题。(区分大小写)

回答by o_ren

This worked out for me: https://robonobodojo.wordpress.com/2017/02/08/installing-pyqt4-on-mac-osx/

这对我有用https: //robonobodojo.wordpress.com/2017/02/08/installing-pyqt4-on-mac-osx/

What did it was brew install cartr/qt4/pyqt

那是什么 brew install cartr/qt4/pyqt