1

I am new in programming. I have an issue. my python code is:

import turtle

turtle.forward(100)
turtle.exitonclick()

I already install turtle on my desktop. But VsCode Error message is:

Traceback (most recent call last): File "d:/Code Practice/Python/turtle.py", line 1, in import turtle File "d:\Code Practice\Python\turtle.py", line 3, in turtle.forward(100) AttributeError: partially initialized module 'turtle' has no attribute 'forward' (most likely due to a circular import)

Nilanka Manoj
  • 3,527
  • 4
  • 17
  • 48
Noman
  • 31
  • 5
  • 1
    Does this answer your question? [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – Sebastian Allard Mar 21 '20 at 14:43

2 Answers2

2

The file you are working on has the same name as the turtle module. So, your file overwrites the module and now you are importing your own file. And that file has no forward function, so it isn't working.

Try renaming your file to something else and give it a try.

0

You have named you file turtle.py because of which python imports that file as the module and also runs the same file while running which creates a loop and gives that error Solution: Name your file something else. For example- turtle_.py or whatever else you want except for the modules name itself as that is reserved for the python interpreter.✌