4

So my teacher in Python showed the turtle module, so I want to try it myself, but when I try to install the turtle module on my PC I have an error:
I'm using "pip" to install modules, so when I do "pip install turtle" on a console
(not Python console) I have an error :

Collecting turtle
using cached 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 "C:\Users\Daxxas\AppData\Local\Temp\pip-build-727hpv0w\turtle\setup.py", line40
except ValueError, ve:
                 ^
SyntaxError: invalid syntax

and there is this in red :

Command "python setup.py egg_info" failed with error code 1 C:\Users\Daxxas\AppData\Local\temp\pip-build-727hpv0w\turtle\

And I don't know what to do. There isn't pip's folder in "Temp".

So how can I fix this to be able to install the turtle module ?

ps : Is it possible to copy/paste something in a console ?

2
  • 2
    The syntax error looks like it is coming from a Python 2.x script being run with Python 3.x
    – elethan
    Oct 19, 2016 at 12:56
  • In which case it's a bug in pip (or the module registered with pypi) that it even tries to install it!
    – tehwalrus
    Oct 19, 2016 at 13:08

3 Answers 3

10

Turtle is already included in the Python standard library; you don't need to install anything.

The library you were installing is a completely different thing (an HTTP proxy, apparently) which looks like it's not compatible with any recent Python version.

5
  • 1
    I don't think there is a problem. Did you try just opening an interactive python session and trying import turtle?
    – tehwalrus
    Oct 19, 2016 at 13:09
  • I've tried in pyCharm, the line went gray like it didn't regonize it
    – daxxas159
    Oct 19, 2016 at 13:12
  • 1
    Went grey or red? imports in pycharm sometimes go grey if they are unused (i.e. you haven't typed any other code yet.)
    – tehwalrus
    Oct 19, 2016 at 13:13
  • Traceback (most recent call last): File "C:/Users/Daxxas/PycharmProjects/turtle/turlebase.py", line 3, in <module> forward(100) NameError: name 'forward' is not defined Process finished with exit code 1 This is what I get with : import turtle forward(100)
    – daxxas159
    Oct 19, 2016 at 13:16
  • 1
    But import turtle worked. You need to read the docs for the module, and either do something like from turtle import * to get the forward function defined, or do turtle.forward(100). (although, looking at the docs, you might need t = turtle.Turtle(); t.forward(100)
    – tehwalrus
    Oct 19, 2016 at 13:18
2

This might be happening because you are trying to install a library that is already included in the standard library.

For example, I was trying to install hashlib using pip and was getting a similar error

python -m pip install hashlib
Complete output from command python setup.py egg_info:
....
File "C:\Users\bla\AppData\Local\Temp\pip-build-l8pg66yd\hashlib\hashlib.py", line 80
        raise ValueError, "unsupported hash type"
                        ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\bla\AppData\Local\Temp\pip-build-l8pg66yd\hashlib\

If you are not able to resolve the library, you might have not correctly setup the python interpreter or SDK in your IDE. Check if that is the case.

0

If you name your file turtle.py, it will give you this error. I figured it out after I had finished checked my Python interpreter, settings, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.