简体   繁体   English

PyCharm 错误,ModuleNotFoundError:没有名为“PyQt5”的模块

[英]PyCharm Error, ModuleNotFoundError: No module named 'PyQt5'

I installed python 3.7 and PyQt5 using pip install PyQt5 command.我使用 pip install PyQt5 命令安装了 python 3.7 和 PyQt5。 when I import the module in python console of pycharm, it is working alright but when I import it into my project files am getting the following error.当我在 pycharm 的 python 控制台中导入模块时,它工作正常,但是当我将它导入到我的项目文件中时,出现以下错误。 I searched through the internet for possible solutions but are not working for me and I also think my problem is different from those that were already asked.我在互联网上搜索了可能的解决方案,但对我不起作用,我也认为我的问题与已经提出的问题不同。 any help?有什么帮助吗?

from PyQt5 import QtCore, uic, QtWidgets
from PyQt5.uic import loadUi
from PyQt5.QtWidgets import QApplication,QDialog
import sys

UIClass, QtBaseClass = uic.loadUiType("projj/firstly.ui")


class MyApp(UIClass, QtBaseClass):
    def __init__(self):
        UIClass.__init__(self)
        QtBaseClass.__init__(self)
        self.setupUi(self)
        self.setWindowTitle('developer in details')
        self.pushButton.clicked.connect(self.on_pushButton_clicked)
        self.pushButton_2.clicked.connect(self.on_pushButton_clicked_2)
        self.pushButton_6.clicked.connect(self.on_pushButton_clicked_6)

and the error am getting is我得到的错误是

Traceback (most recent call last):
  File "C:/Users/pc/PycharmProjects/presents/Main.py", line 1, in <module>
    from PyQt5 import QtCore, uic, QtWidgets
ModuleNotFoundError: No module named 'PyQt5'

I find out that I can just use the available tool in PyCharm which is the IDE am using for python.我发现我只能使用 PyCharm 中的可用工具,这是用于 Python 的 IDE。 By just clicking the red underlined word PyQt5 in this case and a red bulb will appear to the left end of the line >> click the drop down that appear and select install package PyQt5.在这种情况下,只需单击带有红色下划线的单词 PyQt5,行的左端就会出现一个红色灯泡 >> 单击出现的下拉菜单并选择安装包 PyQt5。 it installs the required staff again and everything works fine then.它会再次安装所需的人员,然后一切正常。

It sounds like the Python Console and your project are running two different Python Interpreters.听起来 Python 控制台和您的项目正在运行两个不同的 Python 解释器。

When you start the Python Console the top line should list the interpreter it's using.当您启动 Python 控制台时,最上面一行应该列出它正在使用的解释器。 This is the one you installed PyQt5 to.这是您安装 PyQt5 的那个。

Go to: File -> Settings -> Project: xxxxx -> Project Interpreter and change it to the one that's in your Python Console.转到:文件 -> 设置 -> 项目:xxxxx -> 项目解释器并将其更改为 Python 控制台中的那个。 (Note you may need to add another interpreter by clicking on the gear to the right of the text box listing the interpreters) (请注意,您可能需要通过单击列出口译员的文本框右侧的齿轮来添加另一个口译员)

Installing PyQt5 like this worked for me:像这样安装 PyQt5 对我有用:

python -m pip install PyQt5

You can try to reinstall PyQt5 like this:您可以尝试像这样重新安装 PyQt5:

  • pip uninstall PyQt5

  • python -m pip install PyQt5

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

相关问题 ModuleNotFoundError:没有名为“PyQt5”的模块 - Windows PyCharm - ModuleNotFoundError: No module named 'PyQt5' - Windows PyCharm PyQt5:ModuleNotFoundError:没有名为“PyQt5”的模块 - PyQt5: ModuleNotFoundError: No module named 'PyQt5' 为什么“ModuleNotFoundError: No module named 'PyQt5'”错误一直显示? - Why “ModuleNotFoundError: No module named 'PyQt5' ” Error keeps showing? PyQt5和Anaconda:ModuleNotFoundError:没有名为“ PyQt5”的模块 - PyQt5 and Anaconda: ModuleNotFoundError: No module named 'PyQt5' pip安装后出现“ ModuleNotFoundError:没有名为“ PyQt5”的模块” - “ModuleNotFoundError: No module named 'PyQt5'” after pip install Pycharm 上的错误:ModuleNotFoundError:没有名为“_curses”的模块 - Error on Pycharm: ModuleNotFoundError: No module named '_curses' ModuleNotFoundError:没有名为“scrapy”的模块(PyCharm 中发生错误) - ModuleNotFoundError: No module named 'scrapy' (Error happend in PyCharm) ModuleNotFoundError:PyCharm 上没有名为“pynput”的模块错误 - ModuleNotFoundError: No module named 'pynput' error on PyCharm PyCharm 错误 - 没有名为“sip”的模块(PyQt4) - PyCharm error - No module named 'sip' (PyQt4) ModuleNotFoundError:Pycharm 中没有名为“pandas”的模块 - ModuleNotFoundError: No module named 'pandas' in Pycharm
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM