I'm using VS Code on Ubuntu, and am using the latest version of Python (3.8.5). I'm trying to import turtle but I got errors about module tkinter missing. I also installed it via command line as apt install python3-tk
and got it successfully installed, but turtle doesn't yet seem to work at all. What am I missing?
Here's the short and simple code I've written in VS Code to check if it works or not:
import turtle
import tkinter
s = turtle.getscreen()
turtle.color('Blue')
n = 100
turtle.forward(n)
After I try to run my code, a white window appears for less than a second and disappears again. So it's simply not working. Here's what VS Code tells me:
Any helps will be appreciated:)
Looks like there is no error with the package installation, try this
import turtle
t = turtle.Turtle()
this would create a window
t.forward(100)
turtle.done()
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.