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
(在vs代码终端) -> 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
发布于 2022-08-08 02:02:22
当您可以在(外部终端)中成功运行代码时,它表明这不是包问题。
在评论中,Roland明确表示,您需要通过以下方式为vscode配置正确的解释器:
使用快捷方式"ctrl+shift+P"
"Python: select interpreter"
https://stackoverflow.com/questions/73255158
复制相似问题