---
title: "Python Turtle Not Working? Real Errors and Fixes"
description: "Python turtle not working: a file named turtle.py, a window that closes at once, missing tkinter, ignored keys. The real error messages, fixes and text writing."
canonical: https://learn.modernagecoders.com/python-turtle-not-working
source: src/pages/python-turtle-not-working.html
---
> Python turtle not working: a file named turtle.py, a window that closes at once, missing tkinter, ignored keys. The real error messages, fixes and text writing.

In short

When Python turtle is not working, check four things in order: your file is not named turtle.py (that file hides the real module), the program ends with turtle.done() so the window stays open, tkinter is installed (turtle needs it), and screen.listen() is called if you use keys. Text goes on screen with write(). At Modern Age Coders, turtle graphics is part of our live Python course for children in Grade 3 and above, taught in a group batch or one to one.

Learn it with a teacher

## Three courses that take turtle drawings somewhere

Turtle is a starting point. Each course below begins there and moves on to real programs.

[![Python and AI for Kids course thumbnail](/images/python-kids.webp)  TRT / 01 Python and AI for kids Grades 3 to 8. Turtle art first, then games and smart projects. Open the syllabus →](/courses/python-ai-kids-masterclass)[![Maths Through Coding course thumbnail](/images/maths-through-coding.webp)  TRT / 02 Maths through coding Ages 10 to 15. Angles, shapes and patterns drawn in Python. Open the syllabus →](/courses/maths-through-coding)[![Python for Teens course thumbnail](/images/python-teens.webp)  TRT / 03 Python for teens Ages 13 to 18. From graphics to full projects. Open the syllabus →](/courses/python-complete-masterclass-teens)

Match your symptom

## What you see, what it usually means

Find the row that matches what happened on your screen. Each cause is explained further down the page.

| What happens | What Python printed | Most likely cause |
| --- | --- | --- |
| Error on the first turtle line | module 'turtle' has no attribute 'Turtle' | Your own file is named turtle.py |
| Error before anything runs | Standard library module '_tkinter' was not found | tkinter is missing from this Python install |
| A window flashes and closes | Nothing at all | No turtle.done() at the end of the program |
| Arrow keys do nothing | Nothing at all | screen.listen() was never called |
| Error naming a color | bad color string: bleu | A misspelled color name |
| Error with three numbers as a color | bad color sequence: (240, 160, 80) | Color mode is 1.0, not 255 |
| Error on a turtle command | 'Turtle' object has no attribute 'forwad'. Did you mean: 'forward'? | A typo in the command name |
| Error after closing the window | invalid command name ".!canvas" | A turtle command ran after the window was gone |

The _tkinter and color-sequence messages are quoted from the [turtle documentation](https://docs.python.org/3/library/turtle.html); the others come from our own run of Python 3.13.6 with Tk 8.6 on Windows 11, 17 October 2026. We are not connected with the Python Software Foundation.

Cause number one

## The file named turtle.py: why import turtle stops working

It feels sensible to save your first turtle program as turtle.py. It is also a very common reason import turtle fails, because Python then imports your file instead of the real module.

***Broken · the program is fine, the file name is not**python*

```
# Saved as turtle.py  (the bug is the file name, ours)
import turtle
t = turtle.Turtle()
t.forward(100)
turtle.done()

# Our run, Python 3.13.6:
# AttributeError: module 'turtle' has no attribute
#   'Turtle' (consider renaming 'turtle.py' since it
#   has the same name as the standard library module
#   named 'turtle' and prevents importing that
#   standard library module). Did you mean: 'turtle'?
```

Python 3.13 added the "consider renaming" hint; the Python 3.13 release notes show the same message for a file named random.py. Older versions print only the first part, which is far less helpful.

### Why Python picks your file

The Python tutorial explains that "The directory containing the script being run is placed at the beginning of the search path, ahead of the standard library path." So when your folder holds turtle.py, import turtle finds that file first.

The tutorial adds, flatly: "This is an error unless the replacement is intended." Your file has no Turtle class in it, so the very next line fails.

### The fix, in three moves

Rename the file to something like star_card.py or my_drawing.py. Anything except the name of a module you import.

Run the renamed file and read the first line of any new error. With the real module back, the program either draws or fails on a different, honest line.

Check the folder for other borrowed names too. A file called random.py or math.py breaks those modules in exactly the same way.

The window

## The window closes at once, never opens, or freezes

Turtle draws in a desktop window made by tkinter, Python's interface to the Tk toolkit. Window problems tend to come from that window being closed too early, never being allowed to open, or not being available at all.

### It flashes and closes

When the last line finishes, the program ends and takes the window with it. The documentation says turtle.done() "Must be the last statement in a turtle graphics program." Add it, or use turtle.exitonclick() to close on a mouse click.

### It never opens

The documentation is clear: "Turtle graphics requires the tkinter optional module." If you see an error mentioning _tkinter, this Python install has no Tk support. Running python -m tkinter should open a small test window when tkinter works.

### It freezes or will not close

This usually happens when a program is run twice in one session, or a loop never ends. Close the window, restart the Python shell or kernel, and run the file fresh. Add turtle.done() once, at the very end.

| Setting | What the documentation says | What that means for a student |
| --- | --- | --- |
| python.org Python on Windows or macOS | "The python.org installers for Windows and macOS include it" | Turtle should work after a normal install |
| Python on Linux, including some school setups | Some Linux distributions "may package it separately" | Ask whoever set up the computer to add the Tk package |
| IDLE, the editor that comes with Python | done() must not be used if IDLE runs in -n mode | In a normal IDLE install, done() is fine |
| A browser notebook running on a remote server | Not covered by the turtle documentation | Our reasoning: the code runs on another machine, so there is no desktop window for tkinter to open on your screen |

Quotes from the [turtle](https://docs.python.org/3/library/turtle.html) and [tkinter](https://docs.python.org/3/library/tkinter.html) documentation, read 17 October 2026. tkinter lists Tcl/Tk 8.5.12 as its minimum supported version; our test machine reported Tk 8.6.

How to write in turtle

## How to write text on the turtle screen

Searches for how to write in turtle mostly mean one thing: putting words on the drawing. The command is write(), and the documentation gives its full form as write(arg, move=False, align='left', font=('Arial', 8, 'normal')).

***Working · a star card with a centered message**python*

```
# star_card.py  (ours; any name except turtle.py)
import turtle

screen = turtle.Screen()
screen.bgcolor("lightyellow")
t = turtle.Turtle()
t.color("purple")
t.speed(6)            # 6 is "normal"

for side in range(5):
    t.forward(150)
    t.right(144)      # 5 x 144 = 720: two full turns

t.penup()             # move without drawing
t.goto(75, -60)
t.write("Happy birthday, Ava", align="center",
        font=("Arial", 18, "normal"))
t.hideturtle()
turtle.done()         # keeps the window open
```

We ran a test copy of this program: the star closed neatly and the turtle finished at (75.00, -60.00) facing heading 0.0, because five turns of 144 degrees add up to 720, exactly two full turns.

| Part | What it does | Our tip |
| --- | --- | --- |
| arg | The object to write; its string form appears on screen | Numbers work alone, but joining them to text needs str() |
| align | One of "left", "center" or "right", measured from the turtle | Use "center" for titles and labels |
| font | A triple: (fontname, fontsize, fonttype) | Size 8 is the default and is tiny; try 16 to 24 |
| move | If true, the pen moves to the bottom-right corner of the text | Leave it False unless you are writing a line in pieces |

***Broken, then fixed · the score label mistake**python*

```
# The write() mistake (ours)
points = 42
t.write(points + " points")      # TypeError

# Our run: TypeError: unsupported operand type(s)
#   for +: 'int' and 'str'

t.write(str(points) + " points") # works
t.write(f"{points} points")      # also works
```

The error is ordinary Python, not turtle: a number and a string cannot be added. Convert the number first.

Keys, colors and speed

## Keys that do nothing, colors that crash, and a turtle that is too slow

Once the window opens, the next round of trouble usually comes from three settings that the documentation explains in a line each.

***Working · arrow keys that move the turtle**python*

```
# arrow_keys.py  (ours)
import turtle

screen = turtle.Screen()
t = turtle.Turtle()

def go_up():
    t.forward(20)

def turn_left():
    t.left(30)

screen.onkey(go_up, "Up")
screen.onkey(turn_left, "Left")
screen.listen()       # without this, keys are ignored
turtle.done()
```

The documentation says that to register key events, the TurtleScreen "must have the focus", which is what listen() does. Click the turtle window once too, so the keyboard is talking to it and not to your editor.

### Colors: names, hex codes and number triples

A color name is a Tk color specification string, which the documentation illustrates with "red", "yellow", or "#33cc8c". A misspelling such as "bleu" stops the program with bad color string: bleu.

Three numbers like (240, 160, 80) only work after screen.colormode(255). In the default mode each value must be between 0 and 1.0, and the documentation shows the resulting error: bad color sequence: (240, 160, 80).

### Speed: why 0 is the fastest

speed() takes 0 to 10 or a word. The documentation maps "fastest" to 0, "normal" to 6 and "slowest" to 1, and warns that "speed = 0 means that no animation takes place".

So speed(0) is not "stopped"; it is "draw instantly". For large drawings, students also use tracer(0) with update() to draw everything at once.

Asking the user for input inside turtle works too: textinput() pops up a dialog and, as the documentation notes, returns None if the dialog is canceled, so check for None before using the answer.

Checklist

## Ten checks, in order, for any turtle program that will not work

Our checklist, in the order our teachers use it. Stop as soon as one check explains the error.

1. **Read the last line of the error.** It names the type (AttributeError, TypeError, TurtleGraphicsError) and usually the word that is wrong.
2. **Check the file name.** If it is turtle.py, rename it and delete any cached turtle file in the same folder.
3. **Check the last line of the program.** It should be turtle.done() or turtle.exitonclick(), once, at the end.
4. **Check the capital T.** The module is turtle; the class is Turtle. Our run of turtle.turtle() printed: module 'turtle' has no attribute 'turtle'. Did you mean: 'Turtle'?
5. **Check spelling of commands.** Python 3.13 suggests the nearest real name, as it did for forwad.
6. **Test tkinter on its own.** Run python -m tkinter. If no test window appears, the problem is the Python install, not your code.
7. **Check colors.** Names must be real Tk color names; number triples need colormode(255).
8. **For keys, check listen().** And click the turtle window before pressing anything.
9. **Restart before rerunning.** Close the old window and restart the shell, so an old screen is not still attached.
10. **Make it smaller.** Comment out everything except the first three lines and add lines back one at a time until it breaks.

### When the error appears after you close the window

If a program keeps drawing after the window has gone, tkinter has nothing to draw on. In our test, calling turtle.bye() and then t.forward(50) ended with _tkinter.TclError: invalid command name ".!canvas".

The fix is structure, not luck: draw everything first, then let turtle.done() hold the window open as the final line.

### School assignments

If the drawing is a graded school assignment, we will explain why the program fails and teach the idea behind it, but we do not draw anyone's assignment for them.

In a lesson, students bring the broken file, and the teacher asks them to read the error aloud first. Fixing it themselves is the part that sticks.

Where turtle leads

## From a first square to real programs

Turtle was built for learning. The documentation describes it as an implementation of the drawing tools introduced in Logo in 1967 and notes that its "instant, visible feedback makes it an effective way for learners to encounter programming concepts."

| Classes | What gets drawn | The idea behind it |
| --- | --- | --- |
| 1 to 2 | Squares, triangles, a house | Sequence: commands run in order |
| 3 to 4 | Stars and spirals with for loops | Loops, and angles that add up to full turns |
| 5 to 6 | Functions like draw_flower(size) | Functions and parameters |
| 7 to 8 | Random colors and positions | Variables, random numbers, color modes |
| 9 to 10 | An arrow-key drawing game | Events and the main loop |
| 11 to 12 | A card or poster with text | Putting it all together; write() and layout |

After turtle, children move on to games and data. For age-by-age starting points, see [Python for 10 year olds](/python-for-10-year-olds) and [Python for 12 year olds](/python-for-12-year-olds); for younger children, [online coding classes for US kids](/online-coding-classes-for-kids-usa).

From first line to first game

## Four stages of turtle programming

Where a young coder might be, and what comes next.

| Stage | What it looks like |
| --- | --- |
| 1. Typist | Copies commands line by line from a worksheet |
| 2. Looper | Replaces repeated lines with a for loop |
| 3. Builder | Writes functions that draw shapes of any size |
| 4. Game maker | Uses keys, events and text to make something interactive |

### For parents

A child who can explain why five turns of 144 degrees make a star is doing geometry and programming at once.

Errors are part of the work. The useful question is whether your child reads them before asking for help.

### For kids

Never name your file turtle.py. Give it a name about what it draws.

End every program with turtle.done(). Then the window waits for you.

The catalogue

## Nine courses for young Python coders

Taught live online by a regular teacher, in a batch or one to one.

I

### Kids

Grades 3 to 8

TRT / KID / 01

#### Python and AI for kids

Turtle first, then games.

[Open the syllabus](/courses/python-ai-kids-masterclass)

TRT / KID / 02

#### Scratch coding

Drag-and-drop before typing.

[Open the syllabus](/courses/scratch-programming-complete-course)

TRT / KID / 03

#### Maths through coding

Angles and patterns in code.

[Open the syllabus](/courses/maths-through-coding)II

### Teens

Ages 13 to 18

TRT / TEN / 01

#### Python for teens

Past turtle into real apps.

[Open the syllabus](/courses/python-complete-masterclass-teens)

TRT / TEN / 02

#### Creative coding

Animation and generative art.

[Open the syllabus](/courses/creative-coding-animation-mastery)

TRT / TEN / 03

#### JavaScript for teens

Drawing and games in a browser.

[Open the syllabus](/courses/javascript-course-for-teens-beginners-interactive-web)III

### Going further

Teens and adults

TRT / PRO / 01

#### Problem solving for teens

Loops and logic, harder puzzles.

[Open the syllabus](/courses/problem-solving-dsa-masterclass-teens)

TRT / PRO / 02

#### AI and machine learning for teens

Python models, ages 13 to 18.

[Open the syllabus](/courses/ai-ml-masterclass-teens)

TRT / PRO / 03

#### Python for adults

Zero to advanced, ages 18 and up.

[Open the syllabus](/courses/python-programming-masterclass-zero-to-advanced-college)

How lessons run

## Live turtle lessons from home

Weekdays or weekends, flexible: choose your batch, or for a very personalised plan choose 1-on-1 at your convenience, weekend mornings or weekdays.

Weekdays

Batches placed for US time zones.

Weekends

Popular with younger children.

1-on-1

A schedule built around your child.

### A familiar face

One teacher across the term.

### Screen shared

The teacher sees the turtle window too.

### Broken files welcome

We start from the error.

### Explain, then fix

Children fix their own code.

### Anywhere in the US

A laptop with Python is enough.

### Batch or private

Fifteen to twenty, or one child.

Student work

## What our students drew and built

Work from learners whose first programs were turtle shapes too. More on the [student labs](/student-labs) page.

![NutriLife AI nutrition coach project screenshot](/images/projects/nutrilife.webp)

AI and ML

#### NutriLife

An AI nutrition coach that reads what you eat and works you toward a target.

by Bhavya · [Open it](https://nutrilife-bhavya.lovable.app)

![Misti AI chatbot for maths and coding screenshot](/images/projects/misti.webp)

AI and ML

#### Misti

A chatbot that answers mathematics and programming questions, built and deployed by a student.

by Harshit · [Open it](https://misti.modernagecoders.com)

![GuardianX AI internet safety assistant screenshot](/images/projects/guardianx.webp)

AI and ML

#### GuardianX

An assistant that helps a young person recognise unsafe situations online.

by Vivaan · [Open it](https://guardianx-cybersaver.lovable.app)

![SkyCast weather forecast application screenshot](/images/projects/skycast.webp)

Web app

#### SkyCast

A weather forecasting site with live conditions for any location.

by Krish

Fees

## Fees

Turtle comes free with Python. You pay only for live lessons, charged monthly in US dollars; there is no term-long commitment, and you may stop after any month.

Free first class

USD 0

no card required

- A free first lesson
- Bring the program that broke
- No card required

Book it

Group batch

USD 100

a month, billed in US dollars

- Fifteen to twenty learners
- A regular teacher
- Choose a batch time
- Billed monthly

Start here

One to one

USD 150

a month, billed in US dollars

- One child, one teacher
- Times you choose
- A plan around their ideas

Enquire

What families say

## Rated 4.9 across 547 Google reviews

Google reviews from parents, unedited.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

Questions families ask

## Python turtle problems: common questions

### Why is import turtle not working?

A very common cause is a file of your own named turtle.py in the same folder, which Python imports instead of the real module. Rename it. If the error mentions _tkinter instead, this Python install is missing tkinter, which turtle needs.

### Why does my turtle window close immediately?

The program ended. Put turtle.done() as the last line, which the Python documentation says must be the last statement in a turtle graphics program, or use turtle.exitonclick() to close it with a click.

### How do you write text in Python turtle?

Use write(), for example t.write("Hello", align="center", font=("Arial", 18, "normal")). The text appears at the turtle's position. Convert numbers with str() before joining them to words.

### Why do my arrow keys not work in turtle?

Call screen.listen() after setting up onkey(), and click the turtle window once so it has the focus. The documentation says the screen must have the focus to register key events.

### Does turtle need tkinter?

Yes. The Python documentation says turtle graphics requires the tkinter optional module. The python.org installers for Windows and macOS include it, and running python -m tkinter shows a test window when it is working.

### Why does turtle say bad color string?

The color name is not one Tk recognizes, often a typo. Use a real name such as red or a hex code such as #33cc8c. For number triples up to 255, call screen.colormode(255) first.

### Does Python turtle work on a Chromebook?

Turtle needs a desktop window from tkinter, so it works where a full Python install with tkinter can run. On a school Chromebook that depends on how the device is set up, so ask your teacher which Python environment the class uses.

### Can you do my turtle assignment?

No. We explain why a program fails and teach the idea so the student can finish their own work. We never complete graded assignments.

### What times are classes for US families?

Weekdays or weekends, flexible. Choose your batch, or for a very personalised plan choose 1-on-1 at your convenience, weekend mornings or weekdays.

### How much do turtle and Python classes cost?

The first lesson costs nothing. After that you pay month by month for live teaching, and the fees section on this page shows the amount in US dollars.

Elsewhere on this site

## Related pages

More for US families whose children are starting Python.

### [Coding classes in the USA](/coding-classes-in-united-states)

Our full set of pages for US families.

### [Online coding for US kids](/online-coding-classes-for-kids-usa)

Classes for ages 6 to 14.

### [Python for 10 year olds](/python-for-10-year-olds)

A starting point for fifth graders.

### [Python for 12 year olds](/python-for-12-year-olds)

A starting point for seventh graders.

### [How to debug code](/how-to-debug-code)

A method for any bug, turtle or not.

### [Student labs](/student-labs)

Projects our learners have shipped.

### [Scratch not working](/scratch-not-working-help)

Scratch not working? Saving, sign-in, school network and tablet fixes, from the Scratch Help Center.

### [MakeCode Arcade help](/makecode-arcade-help-for-students)

MakeCode Arcade help: jumping, gravity, tilemap levels and lost projects.

### [Roblox Studio errors fixed](/roblox-studio-errors-fixed)

Roblox Studio errors from the Creator docs: 403, 502, HTTP, endless waits.

Start here

## Book a free first lesson

Tell us what your child is drawing and where it goes wrong. The teacher opens the same program in the first lesson.

Before booking, you can read [how a lesson works](/how-we-teach) or browse [all our courses](/courses) with their syllabuses.

[WhatsApp us](https://wa.me/919123366161?text=Hello%20Modern%20Age%20Coders%2C%20my%20child%20in%20the%20US%20is%20learning%20Python%20turtle%20and%20their%20programs%20keep%20failing.%20Could%20we%20book%20a%20free%20first%20lesson%3F) · [+91 91233 66161](tel:+919123366161) · [connect@modernagecoders.com](mailto:connect@modernagecoders.com)

Our teachers are in India and teach entirely over video, so families anywhere in the US join from home. A WhatsApp message gets the quickest answer.

### Want a class sooner? Book a priority demo

A priority demo is a full class of about 45 to 60 minutes. After the class the mentor sends a written skill report and a personal learning roadmap on WhatsApp. If you enrol, the demo fee is adjusted against your first month's fee. Share your demo Order ID with us on WhatsApp and we take it off.

[Book a priority demo](/book-demo)

## Keep exploring Modern Age Coders

### Related courses and guides

- [After the micro:bit: The Next Step to Python, UK](/after-microbit-next-step-python-uk)
- [Python IndentationError Explained: Every Message and Fix](/python-indentation-error-explained)
- [After Scratch: Moving to Python, for Australian Kids](/after-scratch-next-step-python-australia)
- [Python From the Ground Up: Complete, In-Depth Python Course](/python-from-the-ground-up)
- [AI and Python Academy, Amsterdam](/ai-and-python-academy-amsterdam)
- [Python for Machine Learning](/python-for-machine-learning)
- [Online Coding and Python Classes in Dudley](/online-coding-and-python-classes-in-dudley)
- [Online Coding and Python Classes in Malone, Belfast](/online-coding-and-python-classes-in-malone-belfast)
- [Online Coding and Python Classes in Stonnington, Melbourne](/online-coding-and-python-classes-in-stonnington-melbourne)

### Learn more

- [AI and Python Classes for Teens in Boston, Massachusetts](/ai-and-python-classes-for-teens-in-boston-massachusetts)
- [PCAP Certification Prep: Certified Associate in Python Programming](/courses/pcap-python-certification-prep-course)
- [Python Classes in Dubai](/python-classes-in-dubai)
- [Python for 14 Year Olds: Flask, Django Intro](/python-for-14-year-olds)

### Free resources

- [Python Tutorial for Beginners: Complete Guide](/resources/python)
- [Tuples in Python](/resources/python/tuples-in-python)
- [Decorators and Iterators](/resources/python/decorators-and-iterators)
- [Functions in Python](/resources/python/functions-in-python)

### From the blog

- [Python Tutorials & Guides](/blog/topic/python)
- [File Types in Python: A Complete Beginner's Guide to Working](/blog/file-types-in-python-complete-guide)
- [Why Python is the Most Powerful Skill for Professionals Today](/blog/why-python-most-powerful-skill-professionals-today)
- [Exception Handling in Python: Try, Except, Finally](/blog/exception-handling-in-python)

### Start here

- [What Modern Age Coders families say](/love)
- [Book a free demo class with Modern Age Coders](/book-demo)

Free class[Priority demo](/book-demo)[Call us](tel:+919123366161)

---

*Canonical: https://learn.modernagecoders.com/python-turtle-not-working*
