0

I'm trying to download the Turtle Graphics Package for Python, so I enter the following command into my linux terminal:

myusername@penguin:~/Pys$ pip3 install turtle

And here's the error I encountered:

Collecting turtle
  Using cached https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-c6dr99ga/turtle/setup.py", line 40
        except ValueError, ve:
                         ^
    SyntaxError: invalid syntax

It seems like there's an syntax error in the file I was trying to download. Is there a way I can fix that?

Cyh1368
  • 239
  • 3
  • 10
  • 2
    Evidently the script was written for Python 2 and you're trying to use it in Python 3. In Python 3 it would be `except ValueError as ve:`. – khelwood Apr 08 '20 at 10:54
  • See [Invalid Syntax in except handler when using comma](https://stackoverflow.com/questions/12519554/invalid-syntax-in-except-handler-when-using-comma) – khelwood Apr 08 '20 at 10:56

2 Answers2

0

Turtle graphics is already part of Python standard library, you don't need to install it.

See: https://docs.python.org/3/library/turtle.html

Just import it:

import turtle
dzang
  • 2,160
  • 2
  • 12
  • 21
0

There seems to be an issue with how the setup.py has been written.

To fix this, run

pip3 install turtle

Your output will contain a link to the turtle tar.gz file (https://files.pythonhosted.org/packages/ff/f0/21a42e9e424d24bdd0e509d5ed3c7dfb8f47d962d9c044dba903b0b4a26f/turtle-0.0.2.tar.gz)

run wget <paste_link_here> or manually download the tar.gz file from the link

extract the folder using tar -xvf turtle-0.0.2.tar.gz

go into the turtle directory and open setup.py in any text editor.

At line 40, change

`except ValueError, ve:`

to

except ValueError as ve:

then compress it the folder to a tar file again and then run pip3 install on the local file

pip3 install turtle-0.0.2.tar.xz 

This should fix the problems with the package

Farhad Bharucha
  • 321
  • 2
  • 10