Import PyQt6,QtCore could not be resolved in VSCode

if I run my Python code in Idle it runs but all the menu items are missing (presumably because they came from PyQt.
Running it in vsCode shows the import PyQt6.QtCore (also .QtGui and .QtWidgets) underlined in red in the python coding. When I hover above it there is a message
" Import “PyQt6.Core” could not be resolved PylancereportMissingImports"
Please help me resolve this. I am new to Python programming and only know MS Visual Basic from years ago.

IDLE use tk not PyQt.

You must install PyQt6 either from your systems package manager or using pip.
Did you install PyQt6?

Assuming you are Windows you would need to run this command in a terminal (CMD for example):

py -m pip install PyQt6

Hi Barry. Thanks for your reply.
I am using Mac mini M1 chip OSX14.4.1 Sonoma.
I had installed PyQt6 and this was confirmed when I ran ( a few minutes ago) “pip3 install PyQt6” with reply “Requirement already satisfied”. PyQt6 was installed in a folder env/…/site-packages. It may be path problem which I don’t know how to fix.

It is some times the case that the pip3and the python3 do not match.
On the mac use this command.

python3.12 -m pip install PyQt6

Then you can use python3.12 to run your code.

Thanks Barry.
I tried your command above but still got the same message (and I am using Python 3.12) “Requirement already satisfied”.

If you don’t mind I am changing this topic to Tkinter problem.

I would actually rather use tk but that doesn’t work for me either. It loads the window but none of the Menu items. Hre is an example taken from the Python tutorial:

from tkinter import *
from tkinter import ttk, messagebox
root = Tk()
m = Menu(root)
m_edit = Menu(m)
m.add_cascade(menu=m_edit, label="Edit")
m_edit.add_command(label="Paste", command=lambda: root.focus_get().event_generate("<<Paste>>"))
m_edit.add_command(label="Find...", command=lambda: root.event_generate("<<OpenFindDialog>>"))
root['menu'] = m

def launchFindDialog(*args):
    messagebox.showinfo(message="I hope you find what you're looking for!")
root.bind("<<OpenFindDialog>>", launchFindDialog)

This is the result when I run it in IDLE:
Menu test

It seems to me that Python isn’t communicating with Tkinter or PyQT6

Can you please help me?


That is not useful to do under a topic title about Qt6.
It is also bad to change the existing title radically.
Better to start a new topic with a suitable title.

My apologies. I thought that because neither PyQt6 nor Tkinter were being recognised by Python, it was all part of the same problem. I will create a new topic as requested. Pardon my ignorance.