简体   繁体   中英

ModuleNotFoundError: No module named 'tkinter' after

I have been recently attempting to try out some minor game development with Python 3.9 and have been running into some problems. For some reason, Python does not recognize that I have tkinter installed. From what I have seen online, a big fix is to make sure the path variables are set up correctly. I have already added it to my env variables but that has not seemed to fix anything.

Windows 环境变量

I also know I have it installed, as I see it here in my Python site-packages folder.

Python 站点包

At this point, I am stumped. I do have the import as tkinter as well and not Tkinter. The only thing I can think of now is totally uninstalling Python but I would prefer not to do that if there are any other options.

Here is the code:

import math
import random
import pygame
import tkinter as tk
from tkinter import messagebox


class cube(object):
    rows = 20
    w = 500

I am using Windows 10 and VSCode as well. Anything helps and thanks!

Seems I somehow screwed up my Python installation. Completely removing it from my system and reinstalling seemed to fix all of my issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM