Repository navigation
Tkinter ( tkinter ) not working in Vs code When Imported #15851
Description
Environment data
- VS Code version: 1.50.1
- Extension version (available under the Extensions sidebar): XXX
- OS and version: Windows 10 ( As far as I know
- Python version (& distribution if applicable, e.g. Anaconda): python 3.8.5 Anaconda
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): Conda
- Relevant/affected Python packages and their versions: XXX
- Relevant/affected Python-related VS Code extensions and their versions: XXX
- Value of the
python.languageServersetting: XXX
[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]
Expected behaviour
It creates a gui with4 textboxes
Actual behaviour
gives 100 errors
Steps to reproduce:
[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]
- from Tkinter import *
import Tkinter
import tkMessageBox
top = Tkinter.Tk()
L1 = Label(top, text="My calculator",).grid(row=0,column=1)
L2 = Label(top, text="Number 1",).grid(row=1,column=0)
L3 = Label(top, text="Number 2",).grid(row=2,column=0)
L4 = Label(top, text="Operator",).grid(row=3,column=0)
L4 = Label(top, text="Answer",).grid(row=4,column=0)
- See Console
Logs
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
ModuleNotFoundError: No module named 'Tkinter' PS F:\abeer\abeer pendrive\CODING\code\Abeer Codes\Calculater> & F:/abeer/CODING/Anaconda/python.exe "f:/abeer/abeer pendrive/CODING/code/Abeer Codes/Calculater/script.py" Traceback (most recent call last): File "f:/abeer/abeer pendrive/CODING/code/Abeer Codes/Calculater/script.py", line 3, in import tkMessageBox ModuleNotFoundError: No module named 'tkMessageBox' PS F:\abeer\abeer pendrive\CODING\code\Abeer Codes\Calculater> & F:/abeer/CODING/Anaconda/python.exe "f:/abeer/abeer pendrive/CODING/code/Abeer Codes/Calculater/script.py" Traceback (most recent call last): File "f:/abeer/abeer pendrive/CODING/code/Abeer Codes/Calculater/script.py", line 1, in from Tkinter import * ModuleNotFoundError: No module named 'Tkinter' PS F:\abeer\abeer pendrive\CODING\code\Abeer Codes\Calculater>
Activity
CoderTeam1 commentedon Apr 5, 2021
please tell why this happened
kimadeline commentedon Apr 5, 2021
Hi CoderTeam1, thank you for reaching out.
Does your code work when you run it outside of VS Code? Also, how did you set up your conda environment?
CoderTeam1 commentedon Apr 6, 2021
sorry couldnt reply earlier I am in india and also I didnt think of it being working outside vs code I will try and let you know and I use the base environment for every project ( first project in python )
I read articles yesterday and found out i was using code of python 2 so i changed the code to python 3 but still it is not working
kimadeline commentedon Apr 6, 2021
If it's not working outside of VS Code then there's a problem in your code, not with the extension. I will convert this issue to a discussion, so that others can chime in, and hopefully help you.