0

I was working on a Python project when I had to restart my vscode. After relaunching it for some reason none of my modules won't load and I keep getting the error:

Exception has occurred: ModuleNotFoundError
No module named '_tkinter'
  File "...", line 1, in <module>
    import tkinter as tk
ModuleNotFoundError: No module named '_tkinter'

And all of my other imported modules appear with the orange error underscore.

I made sure to check that the modules were installed and it kept telling me that they are:

Requirement already satisfied: pydub in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages

And I restarted vscode and even reinstalled it but nothing worked.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Daim
  • 3
  • 2
  • 1
    Not sure though what having `pydub` installed has to do with importing `tkinter`. – mkrieger1 Apr 18 '23 at 21:47
  • Does this answer your question? [ModuleNotFoundError: No module named '\_tkinter' on macOS](https://stackoverflow.com/questions/68554782/modulenotfounderror-no-module-named-tkinter-on-macos) – mkrieger1 Apr 18 '23 at 21:48

2 Answers2

0

If you're sure the modules are already installed, maybe check whether you're using the right interpreter. Around the top right, there should be a button saying something like "(Python 3.x.x)", click on that and change the interpreter there and see if it works.

Wong Wai Kwun
  • 93
  • 3
  • 3
  • 10
0
  • Ctrl+Shift+P --> Python: Select Interpreter --> Choose the correct interpreter

    enter image description here

  • The current interpreter version will be displayed in the lower right corner of the vscode interface.

    enter image description here

  • Make sure to execute the script with the Python extension

    enter image description here

JialeDu
  • 6,021
  • 2
  • 5
  • 24