简体   繁体   English

如何为 Python 2.7 安装 PyQT4?

[英]How can I install PyQT4 for Python 2.7?

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 路径吗?

Found out solution:找到解决办法:

I installed PyQtX package, (PyQt binary for Mac OS X) from here .我从这里安装了 PyQtX 包(Mac OS X 的 PyQt 二进制文件)。

and then specified PYTHONPATH with this:然后用这个指定PYTHONPATH

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

After typing in import PyQt4 it worked without any problems.输入import PyQt4它工作没有任何问题。 (Case Sensitive) (区分大小写)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM