Skip to content

Tkinter ( tkinter ) not working in Vs code When Imported #15851

Closed

Description

@CoderTeam1

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.languageServer setting: 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]

  1. 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)

  1. 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>

Why is this not working?

Activity

  1. added
    triage-neededNeeds assignment to the proper sub-team
    bugIssue identified by VS Code Team member as probable bug
    on Apr 5, 2021
  2. CoderTeam1 commented on Apr 5, 2021

    @CoderTeam1
    Author

    please tell why this happened

  3. kimadeline commented on Apr 5, 2021

    @kimadeline

    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?

  4. CoderTeam1 commented on Apr 6, 2021

    @CoderTeam1
    Author

    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

  5. kimadeline commented on Apr 6, 2021

    @kimadeline

    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.

  6. locked and limited conversation to collaborators on Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-debuggingbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions