Jack F
Jack F

Reputation: 553

python turtle on mac not working

I am trying to use a python import of turtle but i get an error:

Traceback (most recent call last):
  File "turtle.py", line 1, in <module>
    import turtle
  File "/turtle.py", line 32, in <module>
    turtle.pensize(2)
AttributeError: 'module' object has no attribute 'pensize'

Does the python come with turtle or i have to download it separately?

My python is 2.7.2

Upvotes: 2

Views: 15666

Answers (2)

user2369288
user2369288

Reputation: 1

using turtle.py is causing the problem here. scrap that and use this instead

import turtle
turtlename = turtle.Turtle()
wn = turtle.Screen()

once you have done this use basic turtle comands like

turtlename.forward(90)

Upvotes: 0

DSM
DSM

Reputation: 353149

You called your file turtle.py, so import turtle imports your program, not the module you want.

Rename your program and delete any turtle.py[co] files.

Upvotes: 8

Related Questions