[英]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-tk
和python-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 配置正确的解释器:
"Python: select interpreter"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.