简体   繁体   English

“未找到PyQt4模块” - 无法使用PyQt打开GUI

[英]'PyQt4 module not found' - Cannot use PyQt to open a GUI

I am very new to using PyQt4. 我是使用PyQt4的新手。 So far, i have used QtDesigner to create the GUI windows i shall be using for my program. 到目前为止,我已经使用QtDesigner创建了我将用于我的程序的GUI窗口。

However, when i run the first bit of python coding to get the user interface to appear, i get an error i cannot find a solution to. 但是,当我运行第一个python编码以使用户界面出现时,我得到一个错误,我找不到解决方案。

Here's the code: 这是代码:

import sys, os
from PyQt4 import QtCore, QtGui, uic

form_class = uic.loadUiType("HomeScreen.ui") [0]

All i am trying to do with this is to load a GUI, which is called 'HomeScreen.ui'. 我想要做的就是加载一个名为'HomeScreen.ui'的GUI。

Upon running this code, the python shell returns an error saying: 运行此代码后,python shell返回错误说:

from PyQt4 import QtCore, QtGui, uic

ImportError: No module named 'PyQt4'

I have Python 3.5 installed, as well as PyQt v4.11.4 and PyQt5.6. 我安装了Python 3.5,以及PyQt v4.11.4和PyQt5.6。

'QtGui' and 'QtCore' are both saved in a folder called PyQt4 (and PyQt5), which are both stored in the path: C:\\Program Files (x86)\\Python\\Python35-32\\Lib\\site-packages 'QtGui'和'QtCore'都保存在名为PyQt4(和PyQt5)的文件夹中,它们都存储在路径中: C:\\Program Files (x86)\\Python\\Python35-32\\Lib\\site-packages

I believe this is where third party modules are supposed to be stored, but python can never find the module and i repeatedly get the same error message. 我相信这是应该存储第三方模块的地方,但是python永远找不到模块,我反复得到相同的错误信息。

Any help would be appreciated. 任何帮助,将不胜感激。

I also work in windows and python 3,just run the execute file to install pyqt: 我也在windows和python 3中工作,只需运行执行文件来安装pyqt:

https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.6/ https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.6/

it works well in my environment 它在我的环境中运行良好

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

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