0

When I try to do the following in python 2.7.8 shell:

>>> import turtle
>>> turtle.demo()

I get the following error:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    turtle.demo()
AttributeError: 'module' object has no attribute 'demo'

This is the first time in my life I try using turtle, and assumed it would be installed when installing python. I can't find it anywhere on my computer and don't know how to get it at the correct place. Can anybody please explain what I have to do to get at least the turtle.demo() working?

unor
  • 92,415
  • 26
  • 211
  • 360
  • Okay, I just tried the following in powershell (windows 7): python -m pydoc turtle. Which gave me the location of the file, being C:\Python27\Lib\lib-tk\turtle.py. I am scrolling through the document and it indeed doesn't have anything called demo(), though there is a function called demo1() and one called demo2(). both don't do anything in the python shell either. – Douwe van der Leest Feb 04 '16 at 10:18

1 Answers1

0

Since demo1() and demo2() are defined under a if __name__ == "__main__": statement, don't try to run them from inside a Python shell, instead run the turtle.py library as if it were a standalone Python program:

python C:\Python27\Lib\lib-tk\turtle.py

that should invoke the two demonstration routines, one after the other. Worth watching just to see the undo feature in action.

cdlane
  • 40,441
  • 5
  • 32
  • 81