Python Forum
"ModuleNotFoundError: No module named 'PyQt5.QtWidgets'; 'PyQt5' is not a package"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"ModuleNotFoundError: No module named 'PyQt5.QtWidgets'; 'PyQt5' is not a package"
#1
Hi, I've been trying to solve this problem with VScode for 2 days:
"ModuleNotFoundError: No module named 'PyQt5.QtWidgets'; 'PyQt5' is not a package".
Of course PyQt5 5.15.6 and Python 3.9.5 pip 21.3.1 are installed.
I've tried everything, searched the internet but nothing to do.
What's strange is that from the Python 3.9.5 shell
I enter 'import PyQt5' and it imports it without problems, but in VScode it gives me the message above.
I think the problem is VScode. Any ideas?
Thanks a lot!


ps
Same example. In the Python shell it works in VScode it doesn't.

Attached Files

Thumbnail(s)
       
Reply
#2
As you use Code Runner add this to code-runner.executorMap.
"php": "php",
"python": "$pythonPath $fullFileName",
"perl": "perl",
Then Code Runner will use version and always switch(eg use virtual environment) to the version shown down in left corner.
You can run this little scripts to see what version used.
import sys

print(sys.executable)
Output:
C:\Python39\python.exe
This is the output when i run in VS Code using Code Runner.
Then from command line can use this to see that version from command line match up.
G:\div_code
λ python -c "import sys;print(sys.executable)"
C:\python39\python.exe

G:\div_code
λ pip -V
pip 21.2.4 from c:\python39\lib\site-packages\pip (python 3.9)
I use cmder(advislble to use),but command is just the same in cmd.
VS Code from start
Reply
#3
Hi, it doesn't work...
Reply
#4
Hi, I reformatted everything and now it works.
Before, it was giving the error message of 2 conflicting exceptions now not. Maybe I have understood. When I installed VScode , python was already installed in my laptop, then VScode suggests me to install Python and I accepted. Could it be that they were running 2 different versions of Python at the same time and it was conflicting by raising 2 exceptions?
Anyway, thanks everyone and have a great day !!! Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  no module named 'docx' when importing docx MaartenRo 1 705 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Database connection problems [login, PyQt5, PySql] gradlon93 5 618 Dec-15-2023, 05:08 PM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 22,934 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,158 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,309 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,388 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,222 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 961 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,188 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 932 May-15-2023, 02:38 PM
Last Post: tonynapoli2309

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020