运行 python 代码 VSCode 和 Pycharm 时不出现 GUI
GUI does not appear when running python code with VSCode and Pycharm
我正在尝试编写一些 python 代码,在我的代码中我导入了 turtle 模块,当我 运行 我在 VSCode 上的代码时,我希望看到一个 GUI window 但我得到了以下错误:
除此之外,我收到 Python 的问题报告显示:
这是我的代码的样子:
import turtle
my_turtle = turtle.Turtle()
my_turtle.shape("turtle")
my_turtle.color("red")
my_turtle.forward(100)
screen = turtle.Screen()
screen.exitonclick()
顺便说一句,我的 macOS 版本是 11.1。
如果我错了请纠正我,但显然 Python 2.7.16 不支持 Turtle 模块,所以我在终端上将我的 python 版本切换到 3.9.1,当我 运行 python main.py
GUI终于出现了
我使用以下命令在我的终端上切换 python 版本:
alias python="python3"
虽然我已经在我的终端上解决了这个问题,但我还没有找到在 VSCode 上更改 python 版本的方法。
也许你应该直接安装 python 3.9.1 到你的机器上,这样你就不用担心了。
我正在尝试编写一些 python 代码,在我的代码中我导入了 turtle 模块,当我 运行 我在 VSCode 上的代码时,我希望看到一个 GUI window 但我得到了以下错误:
除此之外,我收到 Python 的问题报告显示:
这是我的代码的样子:
import turtle
my_turtle = turtle.Turtle()
my_turtle.shape("turtle")
my_turtle.color("red")
my_turtle.forward(100)
screen = turtle.Screen()
screen.exitonclick()
顺便说一句,我的 macOS 版本是 11.1。
如果我错了请纠正我,但显然 Python 2.7.16 不支持 Turtle 模块,所以我在终端上将我的 python 版本切换到 3.9.1,当我 运行 python main.py
GUI终于出现了
我使用以下命令在我的终端上切换 python 版本:
alias python="python3"
虽然我已经在我的终端上解决了这个问题,但我还没有找到在 VSCode 上更改 python 版本的方法。
也许你应该直接安装 python 3.9.1 到你的机器上,这样你就不用担心了。