Trouble with turtles

11 Feb, 2018

Theodore M writes:

Hello. Working in python with my daughter, but stuck on this error:

Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> import turtle Traceback (most recent call last): File "<pyshell#0>", line 1, in import turtle File "/Users/mac/Documents/turtle.py", line 2, in t=turtle.Pen() AttributeError: module 'turtle' has no attribute 'Pen'

It looks as if you might have created a file called turtle.py in your Documents directory (/Users/mac/Documents), and because you're running IDLE from the same directory (I assume), that file is being loaded before the actual turtle module. If you delete this file and try again, hopefully you'll have more success.

Update: for people having a similar problem on Windows (or really any Operating System), who can't find the file to delete, one option is to enter this into the shell:

import turtle
print(turtle.__file__)

That will give you the full path. For example:

>>> print(turtle.__file__)
C:\Users\jason\AppData\Local\Programs\Python\Python37-32\turtle.py