Forum Archive

Turtle turtle.Screen() not working

oDuty

I am on my ipad and i just bought pythonista. I wanted to create something in turtle but i kept on getting the error: module ‘turtle’ has no attribute ‘Screen’
The code:

import turtle as t
playerAscore=0
playerBscore=0

window = t.Screen()
window.title("pong ping")
window.bgcolor("black")
window.setup(width=800,height=600)
window.tracer(0)

I am aware this turtle module is possibly old or unfinished but if there is anything i can do please let me know.a

ccc

Add

window.present()
oDuty

Whereabouts should i add that?

ccc

At the end.

oDuty

Same error happens

cvp

@oDuty For me, that works. Sure you don't have another turtle.py somewhere?

JonB

As a check:

import turtle
print(turtle.__file__)
oDuty

@cvp I’m new to this, what do you mean exactly?

cvp

@oDuty Assume you have written a script named turtle.py, the import turtle you do would import your own script, not the standard one. That's why @JonB advices you to run his little script to see where resides the imported turtle. Try his little script and post the result.

JonB

Add those two lines to the top of the script. Copy the result and paste here.

a common problem is that you created a file called turtle.py where you intended to try out the turtle module. But when you type import turtle, it imports your file, not the actual turtle module.

cvp

@JonB sorry, didn't know you were there...

Maz

so how do we fix the file turtle.py problem

JonB

@Maz don't name your script turtle.py, unless you intend to replace the built in turtle module.