Skip to content Skip to sidebar Skip to footer

Importerror: No Module Named Tkinter When Importing Swampy.turtleworld

I am using Python 3.4 and following along the book 'Think Python: how to think like a computer scientist'. I actually figured out this issue a week ago, but saved over the original

Solution 1:

You're trying to run Python 2 code in Python 3 that loads Python 2 specific modules (Tkinter) and it's not going to work.

The default TurtleWorld package is Python 2, but there is an unsupported Python 3 version from the Green Tea Press' Swampy: Installation Instructions page. Go to the Python 3 section at the bottom. You will either need to install this package manually or just keep it in your working directory and import it from there. (The instructions explain this.)

Another alternative is to use the turtle module that comes with Python 3, as it's functionally similar for most turtle-related experiments. (I've answered TurtleWorld questions on SO using the Python turtle module.) For example:

from turtle import Turtle, Screen

bob = Turtle(shape="turtle")
print(bob)
bob.fd(100)
bob.lt(90)
bob.fd(100)

screen = Screen()
screen.exitonclick()

Post a Comment for "Importerror: No Module Named Tkinter When Importing Swampy.turtleworld"