在 MacOS 下为 Python 2.6 设置 Qt4 和 PyQt
我从 http://qt.nokia.com/downloads/ 下载了 Qt4 并安装了它。
使用 MacPorts,我尝试使用这两行来安装 PyQt 作为 Python 2.6.1(默认情况下安装在 MacOS X Snow Leopard 中)的绑定:
sudo port install py-pyqt4
sudo port install py26-pyqt4
显然这不起作用。如果我尝试在交互式 python-shell 中导入一些 Qt4 模块,则会收到以下错误:
>>> import PyQt4.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4.QtCore
我做错了什么?如何让 Python 运行 Qt4 和 PyQt?
I downloaded Qt4 from http://qt.nokia.com/downloads/ and installed it.
Using MacPorts I tried to install PyQt as a binding for Python 2.6.1 (which is installed by default in MacOS X Snow Leopard) using both these two lines:
sudo port install py-pyqt4
sudo port install py26-pyqt4
Obviously that didnt work. If I try importing some Qt4-Modules in the interactive python-shell, I get the following error:
>>> import PyQt4.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PyQt4.QtCore
What did I do wrong? How do I get Python with Qt4 and PyQt running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己找到了解决方案:PyQt4安装正确,Qt4也是如此。但是,PyQt 安装在 MacPort 的 python 安装中,而不是系统的 python 安装中。为了更改执行“python”时将启动的安装,我使用 macports 选择了 python26:
I found the solution myself: PyQt4 was installed correctly and so was Qt4. However, PyQt was installed in the MacPort's installation of python, not in the system's python-installation. To change the installation that will start when executing "python" I selected python26 using macports: