0

I'm beginning Python, and when I started the module part of the tutorials, it looked like modules members weren't recognized.

I'm on VSCode with python extensions like "Python" and "Python for VSCode". I'm on Windows. I reinstalled Python in C:\Python32 to add it to the path, and went into my computer > properties > advance > variable to add it to the path again.

Example :

import os

import turtle

turtle.forward(100)

os.system("pause")

Error : Module 'turtle' has no 'forward' member

Why aren't the module member understood by VSCode ? I tried to run the code with IDLE, and it even stopped at the turtle import :

import os
import turtle

Traceback (most recent call last):

File "", line 1, in

//File should have pyshell#1 in <> in ""

import turtle

File "C:\Python37-32\turtle.py", line 5, in

my_turtle = turtle.Turtle()       # x is not a good name for a Turtle object

AttributeError: module 'turtle' has no attribute 'Turtle'

Spencer Wieczorek
  • 21,229
  • 7
  • 44
  • 54
Jaune
  • 343
  • 1
  • 8
  • 3
    You have apparently named a program of yours `turtle.py`. That's being imported instead of the actual `turtle` module. – jasonharper Jan 30 '19 at 15:43
  • agreed^ you probably have a file, library, or module polluting your namespace. Make sure you don't have anything named `turtle` or `Turtle`. Maybe try putting your code in a codepen so we can take a look at it. – Frank Jan 30 '19 at 16:52
  • That was it indeed, I called my testing file "turtle.py", since it was about turtle. Thanks a lot to both of you ! – Jaune Jan 30 '19 at 17:22

1 Answers1

1

probably your file name is turtle.py , rename it and give a try .

More information follow this Can't import turtle module in Python 2.x and Python 3.x