Cannot import QtCore or QtGui from PyQt4

房东的猫 提交于 2019-12-11 02:39:09

问题


I have found plenty of posts regarding this issue, but no answers that work for me.

PROBLEM:
I am trying to run this code:
from PyQt4 import QtCore, QtGui
I get this error in return:
ImportError: cannot import name QtCore
I append the path to PyQt4 to sys.path (C:\Python27\Lib\site-packages\PyQt4) and importing just PyQt4 throws no errors. I can see that QtCore.pyd and QtGui.pyd are in that directory and the directory has its __init__.py file.

Specs:
Windows 7 x64
python v2.6.8
PyQt v4.10.4


回答1:


If you're using Python-2.6.x, you will have to use an installer for an earlier version of PyQt4. The most recent version available is for PyQt-4.10/Qt-4.8.4, which can be downloaded from here:

  • PyQt4-4.10-gpl-Py2.6-Qt4.8.4-x64.exe
  • PyQt4-4.10-gpl-Py2.6-Qt4.8.4-x32.exe


来源:https://stackoverflow.com/questions/22622292/cannot-import-qtcore-or-qtgui-from-pyqt4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!