2

I donwloaded PyQt6 using pip install pyqt6 and it had a bunch of errors so I uninstalled it and reinstalled it with pip install pyqt6 --user and the errors dissappeared. problem is trying to use it in VSCODe or any other ide doesn't work. When i write: from PyQt6.QtWidgets import QApplication, QMainWindow, QAction, QMenu, QMessageBox VSCode gives me the error Import "PyQt6.QtWidgets" could not be resolved. Could someone walk me through what I may of done wrong please?

Jerome B
  • 21
  • 1
  • 2
  • Do the answers to this [question](https://stackoverflow.com/questions/2812520/dealing-with-multiple-python-versions-and-pip) help at all? – quamrana Apr 09 '22 at 16:41
  • I don't use VSCode so I'm not sure, but, isn't that just a warning? Have you tried to run the code? Because an actual failed import should show `ImportError: No module named 'PyQt6'` or `ImportError: cannot import name <...>`. Those warnings are often caused by issues from the IDE configuration, but don't automatically mean that the program won't run. – musicamante Apr 09 '22 at 22:37

1 Answers1

0

Try this in VSCode:

  • On the lower right of the VSCode window you should see the language mode and version that VSCode is currently using. Something like "Python" 3.10.7.
  • If you HOVER over this text (like 3.10.7), VSCODE will display the actual path used for that version.
  • If you CLICK on the version, you can change the LANGUAGE MODE and VERSION that is being used by VSCode in the window while editing (and executing) Python code. The language and version reflect the path to the library used.
  • In my case when I looked, the version had changed to a beta version I'd mistakingly installed earlier (3.11.03b). The version I was using when I installed PyQT6 was 3.10.7.
  • When I changed the version back to 3.10.7, suddenly everything worked again.

In my case, I had been moving things around in migrating from PyQT5 to PyQT6 and was now using a different file folder for my migrated code. I opened up a new VSCode Window and then my new PyQT6 folder, and I failed to notice that VSCode had chosen what it thought was the 'latest' version of the interpreter.

cs1
  • 38
  • 5