简体   繁体   English

无法从 PyQt4 导入 QtCore 或 QtGui

[英]Cannot import QtCore or QtGui from PyQt4

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.我将 PyQt4 的路径附加到 sys.path (C:\\Python27\\Lib\\site-packages\\PyQt4) 并且只导入 PyQt4 不会引发任何错误。 I can see that QtCore.pyd and QtGui.pyd are in that directory and the directory has its __init__.py file.我可以看到 QtCore.pyd 和 QtGui.pyd 在该目录中,并且该目录有其__init__.py文件。

Specs:眼镜:
Windows 7 x64视窗 7 x64
python v2.6.8蟒蛇 v2.6.8
PyQt v4.10.4 PyQt v4.10.4

If you're using Python-2.6.x, you will have to use an installer for an earlier version of PyQt4.如果您使用的是 Python-2.6.x,则必须使用 PyQt4 早期版本的安装程序。 The most recent version available is for PyQt-4.10/Qt-4.8.4, which can be downloaded from here:可用的最新版本是 PyQt-4.10/Qt-4.8.4,可以从这里下载:

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

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