when i try to launch a script using turtle the turtle graphics window is not working.
What steps will reproduce the problem?
import turtle
wn=turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle() # Create tess and set some attributes
tess.color("hotpink")
tess.pensize(5)
alex = turtle.Turtle() # Create alex
tess.forward(80) # Make tess draw equilateral triangle
tess.left(120)
tess.forward(80)
tess.left(120)
tess.forward(80)
tess.left(120) # Complete the triangle
turtle.done()
What is the expected output? What do you see instead?
The graphic window opens up but it doesn't produce the output because it stops saying it is not working
pyflakes >=0.6.0 : 1.6.0 (OK)
pycodestyle >=2.3: 2.3.1 (OK)
pygments >=2.0 : 2.2.0 (OK)
pandas >=0.13.1 : 0.20.3 (OK)
numpy >=1.7 : 1.13.3 (OK)
sphinx >=0.6.6 : 1.6.3 (OK)
rope >=0.9.4 : 0.10.5 (OK)
jedi >=0.9.0 : 0.10.2 (OK)
nbconvert >=4.0 : 5.3.1 (OK)
sympy >=0.7.3 : 1.1.1 (OK)
cython >=0.21 : 0.26.1 (OK)
qtconsole >=4.2.0: 4.3.1 (OK)
IPython >=4.0 : 6.1.0 (OK)
pylint >=0.25 : 1.7.4 (OK)
Did you change your graphics backend to Tk before running your code?
HI, thank you for replying. To be honest i have no idea what you are talking about. I presume i didnt do what you said. How can I do it?
Deleted duplicate comment.
@dododoooo In Spyder's preferences, (Ctrl-Alt-Shift-P), you'll find the relevant setting under IPython console > Graphics > Graphics Backend
Yes thank you. I did. Now it works the first time only. Then at the second
time it crushes. I have to close and reopen spyder and try again and it
works again only the first time. I checked this ten times to be sure.
Anyway, what is the difference between the setting you suggested and the
others? Thank you for helping
Il 23 gen 2018 10:43 PM, "C.A.M. Gerlach" notifications@github.com ha
scritto:
Deleted duplicate comment.
@dododoooo https://github.com/dododoooo In Spyder's preferences,
(Ctrl-Alt-Shift-P), you'll find the relevant setting under IPython console
Graphics > Graphics Backend
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/6278#issuecomment-359940739,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiFUkOgBz39nuFkbLq3PenAnhp91RASAks5tNlJ0gaJpZM4Rp-Y8
.
What happens if you remove turtle.done()
and try again?
Can i reply tomorrow to the question? Its 1 am here and i am in the bed :)
I ll try and let you know. I have to remove it since the beginning and/or
replace it with something else?
Il 24 gen 2018 1:01 AM, "Carlos Cordoba" notifications@github.com ha
scritto:
What happens if you remove turtle.done() and try again?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/6278#issuecomment-359974011,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiFUkC2CV6KrlMEnlvyhHbHJgRHAeP4bks5tNnLUgaJpZM4Rp-Y8
.
Sure, don't worry about it ;-)
El 23/01/18 a las 19:04, dododoooo escribió:
Can i reply tomorrow to the question? Its 1 am here and i am in the bed :)
I ll try and let you know. I have to remove it since the beginning and/or
replace it with something else?Il 24 gen 2018 1:01 AM, "Carlos Cordoba" notifications@github.com ha
scritto:What happens if you remove turtle.done() and try again?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/spyder-ide/spyder/issues/6278#issuecomment-359974011,
or mute the thread—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/6278#issuecomment-359974651,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWS7V0rnmdOYghv8INnQZnoe4gO0pPzks5tNnOBgaJpZM4Rp-Y8.
Hi, oh here the situation. i run the script for the first time and it works. if i close the turtle graphic window and the i try to rerun the script it opens the window but it doesnt't execute the operation
I really don't know what happens and we don't have time to help you debug it, sorry.
Ok. I am the first one to experience this problem? Bad luck to me
Il 24 gen 2018 4:17 PM, "Carlos Cordoba" notifications@github.com ha
scritto:
I really don't know what happens and we don't have time to help you debug
it, sorry.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/6278#issuecomment-360167179,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiFUkBXhBxdgWR9zpU2RaNOW_M5_FUmuks5tN0ltgaJpZM4Rp-Y8
.
No, there have been other people, but we don't use turtle, so this will be a wild goose chase for us.
Ok thank you anyways
Il 24 gen 2018 4:37 PM, "Carlos Cordoba" notifications@github.com ha
scritto:
No, there have been other people, but we don't use turtle, so this will be
a wild goose chase for us.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/6278#issuecomment-360173997,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiFUkKyyQ7fkHYvyvTeQ30VKzf4pIWFLks5tN05JgaJpZM4Rp-Y8
.
@ccordoba12 Should we close and resolution:Wontfix or tag and community:Help Wanted this one?
If you think maybe someone can explain the problem leave it open. Otherwise
close it. It was a minor problem since i don t have to use turtle for
serious problem obviusly.
Il 01 feb 2018 3:05 AM, "C.A.M. Gerlach" notifications@github.com ha
scritto:
@ccordoba12 https://github.com/ccordoba12 Should we close and
resolution:Wontfix or tag and community:Help Wanted this one?—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/6278#issuecomment-362134587,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiFUkAFfGAd5d3l1H0wdOqU5d1cFz7prks5tQRvegaJpZM4Rp-Y8
.
I just ran the code above and had no issues using a windows computer.
Ok there is some problem with mine evidently. I use windowa as well. You
can close the problem . Thank you anyway
Il 01 feb 2018 7:14 PM, "louieabx" notifications@github.com ha scritto:
I just ran the code above and had no issues using a windows computer.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/6278#issuecomment-362354055,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AiFUkMUp1yRK-GNMzx0wtCLnn6LiuifRks5tQf76gaJpZM4Rp-Y8
.
Thanks @louieabx and @dododoooo , will do.
I know this is closed because of lack of resources to address. I'm adding the following
for informational purposes.
Turtle graphics are a useful tool for visualizing L-Systems and fractals, as described in "The Algorithmic Beauty of Plants". I find it a very useful educational and visualization tool for some things. Everything works great in Linux. Unfortunately, for teaching purposes, I'm force to use a Windows computer. The module appears to work fine, as long as I don't click on the turtle window itself. When I click on the turtle window, it crashes and takes the python kernel down with it.
This is a python 3 anaconda installation of spyder
@ccordoba12 testing a little bit with Turtle
I came with some tips to run a script multiple times in Spyder or prevent the crash of the IPython kernel when trying to run a script that uses Turtle
(at least on Windows):
turtle.done()
with turtle.bye()
and use the Inline
or Automatic
backend for the IPython Console (Preferences
> IPython Console
> Graphics
> Graphics Backend
). As an example:import turtle
wn=turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle() # Create tess and set some attributes
tess.color("hotpink")
tess.pensize(5)
alex = turtle.Turtle() # Create alex
tess.forward(80) # Make tess draw equilateral triangle
tess.left(120)
tess.forward(80)
tess.left(120)
tess.forward(80)
tess.left(120) # Complete the triangle
alex = turtle.forward(100)
turtle.done()
turtle.bye()
The call of turtle.bye()
will raise a Terminator
error but the IPython kernel will not die. To prevent the output of the exception you can use a try-except
:
...
turtle.done()
try:
turtle.bye()
except turtle.Terminator:
pass
The reason for this is to clean some elements used by Turtle
after running.
Run
> Configuration per file...
> Select Execute in an external system terminal
over the Console
section.These are great news @dalthviz! Thanks a lot for digging into this one.
So we need to do two things to fix this issue:
turtle
programs in Spyder.turtle.bye
in spyder-kernels
to avoid it raising a Terminator
exception. See here for an example of patching a builtin method and do this against the 0.x
branch.@juanis2112, could you confirm if @dalthviz findings work on macOS too? Thanks!
@ccordoba12 the new wiki page to run turtle scripts
Great job @dalthviz ! Your writing looks very good to me.
Great, thanks @dalthviz! It looks really good, I only made a couple of minor modifications to it.
Pinging @juanis2112 here again. @juanis2112, does @dalthviz solution works for you on macOS?
@ccordoba12 Yes it works on macOS.
Nice, thanks for the confirmation @juanis2112!
These are great news @dalthviz! Thanks a lot for digging into this one.
So we need to do two things to fix this issue:
1. Please open a page in our wiki (similar to the PyQt one), explaining people how to run `turtle` programs in Spyder. 2. Please patch `turtle.bye` in `spyder-kernels` to avoid it raising a `Terminator` exception. See [here](https://github.com/spyder-ide/spyder-kernels/blob/0.x/spyder_kernels/customize/spydercustomize.py#L203) for an example of patching a builtin method and do this against the `0.x` branch.
How and where can i edit the spyder-kernels so that this piece of code is runned automaticaly at start of spyder? Is it to add in the Pythonstartupfile?
Hi @trixxx3 what do you mean by this piece of code? Do you refer to the patch done for turtle at PR spyder-ide/spyder-kernels#90?
This fix was part of Spyder 3.3.4 so you should have it if you install such Spyder version or a more recent version (3.3.6)
From the beginning,
i started to write a skript with turtle and wanted to use in the ipyhon console. After i added
turtle.done()
at the end of my skript I was able to close the window and end the script. But with a second run i got the TERMINATOR error. Like You posted on 17. Feb I added
turtle.done()
try:
turtle.bye()
except turtle.Terminator:
pass
which prevents the error but i still have to close the window manually. Then i found what ccordoba12 posted on 19. Feb
2.) Please patch turtle.bye in spyder-kernels to avoid it raising a Terminator exception. See here for an example of patching a builtin method and do this against the 0.x branch.
where you find
#==============================================================================
# Turtle adjustments
#==============================================================================
# This is needed to prevent turtle scripts crashes after multiple runs in the
# same IPython Console instance.
# See Spyder issue #6278
try:
import turtle
from turtle import Screen, Terminator
def spyder_bye():
try:
Screen().bye()
turtle.TurtleScreen._RUNNING = True
except Terminator:
pass
turtle.bye = spyder_bye
except:
pass
Which should fix it automatically on running the ipython console but i dont know how to include it.
Is the solution to add your code at every end of turtle skripts?
Thank You for helping ; -)
@trixxx3 which Spyder version are you running? try updating Spyder. Also, here we have some options to run turtle scripts within Spyder
I was running spyder 3.3.3 and its working now in 3.3.6. But turtle.bye( ) does not close the window
I was running spyder 3.3.3
This was fixed in Spyder 3.3.4, as you can in the "Milestone" tag you can find to the right of this issue. So you need to update to our latest version (3.3.6) and you'll get the fix for this.
Most helpful comment
@ccordoba12 testing a little bit with
Turtle
I came with some tips to run a script multiple times in Spyder or prevent the crash of the IPython kernel when trying to run a script that usesTurtle
(at least on Windows):turtle.done()
withturtle.bye()
and use theInline
orAutomatic
backend for the IPython Console (Preferences
>IPython Console
>Graphics
>Graphics Backend
). As an example:The call of
turtle.bye()
will raise aTerminator
error but the IPython kernel will not die. To prevent the output of the exception you can use atry-except
:The reason for this is to clean some elements used by
Turtle
after running.Run
>Configuration per file...
> SelectExecute in an external system terminal
over theConsole
section.