PyCharm Turtle Help!


I am fairly new to Python and PyCharm and i am currently learning about turtle, but i am not able to use it in Pycharm. I have tried 'import turtle' and then written some code after but all i am getting back is an error message. I i go to IDLE and run the code in that it works but i would much prefer to use PyCharm. If anyone could help me out i would really appreciate it!



This is the error message i am getting

Traceback (most recent call last):
  File "C:/Users/Jeff/PycharmProjects/untitled1/new", line 1, in <module>
    import turtle
  File "C:\Users\Jeff\PycharmProjects\untitled1\", line 2, in <module>
    t = turtle.Pen()
AttributeError: module 'turtle' has no attribute 'Pen'


Not sure what Zendesk is, but I'm having the same problem.  I'm paying for this product and IDLE Python is free.  I can use turtle from IDLE Python with no problem at all.  The import statement doesn't fail, but I am unable to use any of the turtle methods without error.  Uses the same interpreter as IDLE Python, so what's the deal?


Could you please attach a screenshot with this error in PyCharm? Please, also show your project tree on this screenshot (a left pane with your project files).


The problem is in \Lib\

Magic variable __all__ is defined as follows:

__all__ = (_tg_classes + _tg_screen_functions + _tg_turtle_functions +
_tg_utilities + ['Terminator']) # + _math_functions)

And PyCharm does not execute this code while scanning packages. So PyCharm can not define which functions can be used in module-level.

So you can change

# __all__ = (_tg_classes + _tg_screen_functions + _tg_turtle_functions +
# _tg_utilities + ['Terminator']) # + _math_functions)
__all__ = ['ScrolledCanvas', 'TurtleScreen', 'Screen', 'RawTurtle', 'Turtle', 'RawPen', 'Pen', 'Shape', 'Vec2D', 'back',
'backward', 'begin_fill', 'begin_poly', 'bk', 'addshape', 'bgcolor', 'bgpic', 'bye', 'clearscreen',
'colormode', 'delay', 'exitonclick', 'getcanvas', 'getshapes', 'listen', 'mainloop', 'mode', 'numinput',
'onkey', 'onkeypress', 'onkeyrelease', 'onscreenclick', 'ontimer', 'register_shape', 'resetscreen',
'screensize', 'setup', 'Terminator', 'setworldcoordinates', 'textinput', 'title', 'tracer', 'turtles',
'update', 'window_height', 'window_width', 'write_docstringdict', 'done', 'circle', 'clear', 'clearstamp',
'clearstamps', 'clone', 'color', 'degrees', 'distance', 'dot', 'down', 'end_fill', 'end_poly', 'fd',
'fillcolor', 'filling', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly', 'getturtle', 'goto',
'heading', 'hideturtle', 'home', 'ht', 'isdown', 'isvisible', 'left', 'lt', 'onclick', 'ondrag', 'onrelease',
'pd', 'pen', 'pencolor', 'pendown', 'pensize', 'penup', 'pos', 'position', 'pu', 'radians', 'right', 'reset',
'resizemode', 'rt', 'seth', 'setheading', 'setpos', 'setposition', 'settiltangle', 'setundobuffer', 'setx',
'sety', 'shape', 'shapesize', 'shapetransform', 'shearfactor', 'showturtle', 'speed', 'st', 'stamp', 'tilt',
'tiltangle', 'towards', 'turtlesize', 'undo', 'undobufferentries', 'up', 'width', 'write', 'xcor', 'ycor']

Also you can use Turtle class:

T = turtle.Turtle()


Duplicates support request in Zendesk.


Odd, with all the reference errors, I was still able to successfully run the script.  I still would like to have the code completion and get rid of the reference errors; I imagine they are directly related.



you can watch this youtube video hope it helps. 


Pycharm turtle problem solution

The problem is in your file name yes ! In your file name
1st rename the file other than the
For ex than run the then it will definitely works fine in pycharm .

don't use the run button as it will run the previous file


Please sign in to leave a comment.