Ask coding questions

← Back to all posts
Is "import turtle" supported under the Python 3 compiler?
zippykins (4)

I'm sorry if this is a simple question or if I had made an error somewhere, im a beginner to coding in general so bear with me.
I'm trying to run a simple program using the turtle command and everytime i run it on this site I get an error that reads "_tkinter.TclError: no display name and no $DISPLAY environment variable". When I try to run this code on other compilers it runs just fine. I feel like I may be making a very simple mistake, below is the code:

import turtle
tut = turtle.Pen()
count = 0

for x in range(8):
tut.forward(50)
tut.right(45)
count = count+1
print("Loop cycles: " + str(count))
if count > 7:
print("The octagon has completed.")

Commentshotnewtop
IzikBen_Zaken (3)

Any estimation for when the python_turtle will work with Python 3?

timmy_i_chen (1097)

Unfortunately not, as we don't support Tkinter, but we have an environment specifically for python turtle: https://repl.it/languages/python_turtle - let me know if it works!

Michael_MarsMar (0)

@timmy_i_chen Unfortunately, that makes using repl very difficult for teaching an introduction to Python in a course that also uses turtle as a teaching tool. It would be no big deal except that division works completely differently in Python 3 vs. python 2, and printing to the console is also a challenge.

I'd rather not have to deal with those language issues in an introductory class.

If you could add support for _ future _ division and print_function, that would take care of the teaching case! Probably more feasible than adding support for tkinter for sure.

1ool (0)

@timmy_i_chen
This does not work. See the screenshot.

Why doesn't "finally" work? It works in Python 3

timmy_i_chen (1097)

@1ool Our version of python turtle uses python 2 - we can and will update this.

gorelhedin (4)

@timmy_i_chen
Running the turtle with python 3 would be really great for teaching purposes. Do you have any time plan for when this will be implemented?

gorelhedin (4)

@Michael22Omega I don't know. I haven't heard anything. Would also appreciate this a lot. @timmy_i_chen What is the status of python turtle for Python 3?

pwinston (0)

Ugh, this is huge drag. I started a class using Python 3, then I decided I wanted to use Turtle so I made a new Python w/ Turtle class and copied in all my assignments. Now I realize it's Python 2.

Ugh, Python 3 came out 12 years ago! I'm not sure I can use repl.it with this limitation, I want graphics but it's crazy to make people learn all the oddities that are 2 vs. 3. Ugh this really creates a bad situation.