Python Forum
[PyQt] ModuleNotFoundError: No module named 'PyQt5' - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [PyQt] ModuleNotFoundError: No module named 'PyQt5' (/thread-27290.html)



ModuleNotFoundError: No module named 'PyQt5' - matklt - Jun-01-2020

I have installed PyQt5 and PyQt5-tools using command prompt and pip install PyQt5 then pip install PyQt5-tools everything installed fine
I then put in the following code

from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
import sys

def window():
    app = QApplication(sys.argv)
    win = QMainWindow()
    win.setGeometry(200, 200, 300, 300)
    win.setWindowTtitle("Darts Scoreboard")

    win.show()
    sys.exit(app.exec_())

Window()
but get the following traceback
Error:
C:\Users\44787\PycharmProjects\untitled\venv\Scripts\python.exe C:/Users/44787/PycharmProjects/untitled/Scoreboard.py Traceback (most recent call last): File "C:/Users/44787/PycharmProjects/untitled/Scoreboard.py", line 1, in <module> from PyQt5 import QtWidgets ModuleNotFoundError: No module named 'PyQt5'
I have checked alsort of youtube help advice and instructions and nothing seems to work can someone please please help

Thanks


RE: Help Needed loosing my mind - menator01 - Jun-01-2020

Please use tags when posting code.
This works for me
#! /usr/bin/python3
from sys import exit as sysExit
import sys
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow

def window():
    app = QApplication(sys.argv)
    win = QMainWindow()

    win.show()
    sysExit(app.exec_())

window()



RE: ModuleNotFoundError: No module named 'PyQt5' - Knight18 - Jun-02-2020

I think the problem here is that you didn't install PyQt5 properly. Do you have multiple Python installations or something?