python turtle on mac not working

11,433

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.

Share:
11,433
Jack F
Author by

Jack F

please delete me

Updated on June 16, 2022

Comments

  • Jack F
    Jack F almost 2 years

    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

  • Jack F
    Jack F about 11 years
    I renamed the file and still get the same thing
  • DSM
    DSM about 11 years
    If by "the same thing" you mean AttributeError: 'module' object has no attribute 'pensize', then you're still getting the wrong module. Type import imp and then print imp.find_module("turtle") to see what file it's trying to import.
  • Jack F
    Jack F about 11 years
    i got it, i had another file called turtle.pyc and it was conflicting with the import.