0

I'm using elpy and python3 in Ubuntu.

I have the following python code in a file called turtleTest.py:

from turtle import Turtle, Screen

timy = Turtle()
timy.shape("turtle")
timy.fillcolor("red")

my_screen = Screen()
my_screen.exitonclick()

When I open a new python shell with M-x run-python and send the above code to the shell with C-c C-c for the first time, it runs as expected. But, if I try to send it to the shell a second time (also using C-c C-c), it throws an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/gp/Documents/python/udemyPython100daysOfCode/day16_OOP/turtleTest.py", line 3, in <module>
    timy = Turtle()
  File "/usr/lib/python3.8/turtle.py", line 3814, in __init__
    RawTurtle.__init__(self, Turtle._screen,
  File "/usr/lib/python3.8/turtle.py", line 2558, in __init__
    self._update()
  File "/usr/lib/python3.8/turtle.py", line 2661, in _update
    self._update_data()
  File "/usr/lib/python3.8/turtle.py", line 2647, in _update_data
    self.screen._incrementudc()
  File "/usr/lib/python3.8/turtle.py", line 1293, in _incrementudc
    raise Terminator
turtle.Terminator

If I run the code from the terminal (python3 turtleTest.py), it runs fine as many times as I run it.

gp@Cerberos:~$ emacs --version
GNU Emacs 26.3
gp@Cerberos:~$ python3 --version
Python 3.8.10

When I M-x list-packages and search for elpy:

 elpy               20220922.2253 installed             Emacs Python Development Environment

M-x elpy-config:

Elpy Configuration

Emacs.............: 26.3
Elpy..............: 1.35.0
Virtualenv........: None
Interactive Python: python3 3.8.10 (/usr/bin/python3)
RPC virtualenv....: rpc-venv (/home/gp/.emacs.d/elpy/rpc-venv)
 Python...........: python 3.8.10 (/home/gp/.emacs.d/elpy/rpc-venv/bin/python)
 Jedi.............: 0.18.2
 Autopep8.........: 2.0.1
 Yapf.............: 0.32.0
 Black............: 22.12.0
Syntax checker....: flake8 (/home/gp/.local/bin/flake8)

Posible duplicates checked:

I checked this question (without answer) but it seems to be related to a different problem.

What am I doing wrong and how can I fix this?

PavoDive
  • 6,322
  • 2
  • 29
  • 55

0 Answers0