Can Tkinter "uninstall" itself? - python

I was working on an app with Tkinter and everything was working fine, but after modifying a function (that has nothing to do with the Tkinter environment) all of a sudden I started getting the following error:
from tkinter import *
ImportError: No module named tkinter
I tried opening another Tkinter file to see if it had something to do with my app, but on the other file, I'm also seeing the same error. So I'm guessing it doesn't have to do with my app. Is there any way that Tkinter uninstalled itself if it was working before? I'm also getting the same error when importing Pandas. It's weird because it was all working before.
Has anyone encountered this problem before? What could be the problem?

No python module can uninstall itself. You can type pip install tkinter again in cmd.

Related

PyOpenGL isnt a package

Trying to run a basic pygame based PyOpenGL window and it returns an error.
I have reinstalled them both from https://www.lfd.uci.edu/~gohlke/pythonlibs/
Code:
import pygame as pg
from OpenGL.GL import *
Error:
ModuleNotFoundError: No module named 'OpenGL.GL'; 'OpenGL' is not a package
Tried running it, expected a window with a blue/grey background. recieved an error in VS Code terminal and anger
cgohlke's comment was right, the file I was using was called OpenGL.py changed the name and it worked fine

importing turtle module in VS Code gives ModuleNotFoundError: 'tkinter'

I am trying to import turtle module. but it shows me module name 'tkinter' is not found. although it is a built-in module.and i didnt import it directly.(i think turtle module imports tkinter for me.)
I tried changing the path for Python in VS Code by clicking the bottom left option is status bar.
other modules are getting imported(import random, etc)
I have attached the screenshot of the code and error i am getting.
Please HELPPP!!!!
It can also be an import error that you facing with you IDE (VS Code). Try changing the target exe to the python interpreter in your virtual environment. You can learn more about this, by visiting the link below:
https://medium.com/nerd-for-tech/import-errors-in-python-no-module-named-module-name-for-vs-code-887d1f78cf02

How do I fix Tkinter in Python-3.7?

I've tried to create a window with Tkinter but it does not work...
I am using MacOS with Python 3.7.3 in VSCode.
Maybe you can help me by this:
from tkinter import *
root = tk.Tk()
root.mainloop()
I tried many of these code versions but every time I run any of these programms he tells me:
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I'd really like to use Tkinter but I don't now what to do...
I hope you can help me!
Thank's
I recommend re installation of python from official site.

How do I import Tkinter? [duplicate]

This question already has answers here:
ImportError when importing Tkinter in Python [duplicate]
(3 answers)
Closed 6 years ago.
When I try to import tkinter, this is the message I get:
Traceback (most recent call last):
File "Num_inc_dec.py", line 1, in <module>
from Tkinter import *
ImportError: No module named Tkinter
I've searched for my error and have found nothing. I've tried just typing import Tkinter. I'm using python 2.7, but just in case I have also tried using a lower case t.
Additional:
I'm using cygwin to launch my .py files as I'm new to programming, and that was in the tutorial to setting up an environment to work in that I used. I suspect this is part if not the error as I can find nothing online fixing my problem.
Edit: I fixed it. When installing cygwin I had to enable something to get it to work. I searched tkinter and enabled it from the thing that came up.
"The Python Windows Installers include Tcl/Tk as well as Tkinter. These are essentially a one-click install of everything needed." http://tkinter.unpythonic.net/wiki/How_to_install_Tkinter
I would check that you are actually running the correct version of Python.
Perhaps try explicitly stating you would like to run 2.7 with
$python2.7
>>> import Tkinter
As
import Tkinter
will return an ImportError in python 3.5. But will execute correctly in 2.7.
Then if the problem has not been solved, just reinstall python 2 with the windows installer. Tk and Tkinter are packaged with the python installer.

Why is Tkinter missing?

Started messing with Tkinter today, but when I tried to run my first program it crashed. It appears the reason is that I don't have Tkinter. This is a standard installation of Python 3.3 on Windows 7, why is it not there? How can I get it?
This answer might be irrelevant with more information, but, for now: are you capitalizing "Tkinter" when using the import command? In Python 3.x, it's imported as lower-case ("import tkinter"), but in 2.x code it's imported with an initial capital ("import Tkinter").
Maybe you disabled it during Python installation? It is Tcl/Tk item in install wizard and it can be disabled. Try reinstall Python and do not turn it off.
Both of the answers above are perfectly good ideas but if neither of these work make sure you are using this code:
from tkinter import *
Rather than this code:
import tkinter

Categories