Question

I'm trying my hands on Turtle but I can't get the module installed.

I have searched a lot and people seems to imply that it is included in the Python standard library with Tkinter but this doesn't seem to be the case for me.

when I do:

import Tkinter 

everything seems ok. But when I try

t1 = Turtle()

I get the error

NameError: name 'Turtle' is not defined

As per the tutorial I'm suppose to import like this:

from turtlegraphics import Turtle

But no matter what I've tried I cant find how I can get the library installed.

Était-ce utile?

La solution

You need to import it from the turtle module.

from turtle import Turtle
t1 = Turtle()
t1.forward(100)

Autres conseils

Try to check within the library files whether there is a file called turtle in it . I had the same problem and i found the library file and opened it. So check it and see if it will fix your problem. Most probably turtle library file will be in Lib folder.

Nothing here worked for me. This is what I did: I checked what configuration I had (in the upper right hand corner). I changed it so it was the python version that ran through the project and not just plain python. Then you also have to go to script path (also a setting in the configuation) and set it to the .py that you are working on :)

hey all of you guys just check importing that module ,you dont get any errors its already in standard libraray

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top