ImportError:无法导入名称QtGui或任何其他PyQt4模块

我在Mac Yosemite 10.10.5上使用PyQt4。 和Python 2.7。 当我尝试使用我获得的崇高文本运行一个简单的脚本时

´ImportError: cannot import name QtGui. 

但是,当我通过终端进入python并输入以下行时,它似乎接受它。

>>> from PyQt4 import QtGui
>>> 

我试图在Sublime Text中运行的脚本是:

import sys


from PyQt4 import QtGui


def main():

    app = QtGui.QApplication(sys.argv)

    w = QtGui.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()

    sys.exit(app.exec_())


if __name__ == '__main__':
       Main()

我的Pyqt4路径位于/Library/Python/2.7/site-packages。

我的系统路径输出是:

['','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat -mac','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages','/System/Library/Frameworks/Python.framework/Versions/2.7 / Extras / lib / python','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk','/System/Library/Frameworks/Python.framework/Versions/2.7 /lib/python2.7/lib-old','/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload','/Users/cameronmacintyre/Library/Python/2.7 / lib / python / site-packages','/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC','/Library/Python/2.7/site-packages']

我用sip安装,PyQt4安装了以下内容:

python configure.py -q /usr/bin/qmake-4.8 -d /Library/
Python/2.7/site-packages/ --use-arch x86_64
•
make 
•
sudo make instal

我搜查了其他类似的问题几天,并找不到解决方案。 我有点新手,所以任何帮助将不胜感激。

ps我有一段时间安装了Python 3,但我删除它。

链接地址: http://www.djcxy.com/p/55277.html

上一篇: ImportError: cannot import name QtGui or any other PyQt4 module

下一篇: Why won't modules in pycrypto work?