繁体   English   中英

ModuleNotFound(tkinter),但我已经尝试了我发现的所有东西,但没有任何效果

[英]ModuleNotFound (tkinter), but I've tried everything I found and nothing works

Linux,pop_os,vs代码,python3

import tkinter as tk
win = tk.Tk()
win.title("Hello World")
win.mainloop()

python main.py -> ModuleNotFoundError: No module named 'tkinter'

python3-tkpython-tk已经安装了 apt

python --version (在 vs 代码终端)-> Python 3.9.9

pip3 install tk (in vs code terminal) -> Requirement already satisfied: tk in /var/data/python/lib/python3.9/site-packages (0.1.0)

pip3 install tkinter (在 vs 代码终端中)-> ERROR: Could not find a version that satisfies the requirement tkinter (from versions: none) ERROR: No matching distribution found for tkinter

当在外部终端可以成功运行代码时,说明这不是package问题。

在评论中,Roland Smith 明确表示需要通过以下方式为 vscode 配置正确的解释器

  1. 使用快捷键“ctrl+shift+P”
  2. 键入"Python: select interpreter"
  3. 选择正确的口译员。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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