0

I'm a beginner and started playing around with turtle graphics. When I ran this simple program that I'm positive would work this weird error message popped up. No matter what I do on turtle, its the same message. Can anyone tell me how to fix this problem?

This was my code which when it works, is supposed to make a star.

import turtle
window = turtle.Screen()
slowpoke = turtle.Turtle()

slowpoke.forward(100)
slowpoke.right(144)
slowpoke.forward(100)
slowpoke.right(144)
slowpoke.forward(100)
slowpoke.right(144)
slowpoke.forward(100)
slowpoke.right(144)
slowpoke.forward(100)
slowpoke.right(144)
slowpoke.forward(100)
slowpoke.right(144)

turtle.Screen().exitonclick()

This is the error that showed up:

Traceback (most recent call last):
  File "c:/Users/Laker/Desktop/vs code/learningturtle.py", line 1, in <module>
    import turtle
      File "C:\Users\LULIANG\AppData\Local\Programs\Python\Python38\lib\turtle.py", line 107, in <module>
    import tkinter as TK
      File "C:\Users\LULIANG\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 39, in               <module>
    import re
  File "C:\Users\LULIANG\AppData\Local\Programs\Python\Python38\lib\re.py", line 127, in <module>
    import functools
  File "C:\Users\LULIANG\AppData\Local\Programs\Python\Python38\lib\functools.py", line 18, in <module>
    from collections import namedtuple
  File "C:\Users\LULIANG\AppData\Local\Programs\Python\Python38\lib\collections\__init__.py", line 21, in <module>
    from operator import itemgetter as _itemgetter, eq as _eq
    ImportError: cannot import name 'itemgetter' from 'operator' (c:\Users\LULIANG\Desktop\vs code\operator.py)
PS C:\Users\LULIANG\Desktop> 

All the codes I simply copy pasted from my VS Code

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30

1 Answers1

0

You have created your own file called operator.py. That is the problem. If you have a file with the same name as a library module, that hides the library module. You need to choose a different name.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30