[Tutor] Fwd: : Turtle
Steven D'Aprano
steve at pearwood.info
Thu Jun 23 21:15:43 EDT 2016
On Thu, Jun 23, 2016 at 02:13:56PM -0700, Hershel Millman wrote:
> What I typed was:
>
> import turtle
> turtle.pendown()
What do you get if you print turtle.__file__?
> (And pendown was highlighted in pycharm, indicating that it was not a valid command.)
>
> The error message I received was:
>
> /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5
Look at the version number: you are running Python 2.5.
Now look at the result you got earlier:
> >> /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py
Look at the version number: you are running Python 2.6.
So you have AT LEAST two different Python versions on your computer.
That's fine, I have *nine* versions on mine. But it does mean you have
to be a little more careful to ensure you are using the right one.
My *guess* is that your Mac has pre-installed version 2.5 with the
operating system, and you have installed version 2.6 next to it, and now
you sometimes get 2.5 and sometimes 2.6 depending on which icon you
double-click. Or something like that. Or maybe PyCharm let's you pick a
different version, and you haven't noticed.
You can check the version from inside Python:
import sys
print sys.version
My prediction is:
* when you run Python 2.6, turtle will work fine, including the pendown
command (but remember to use round brackets/parentheses):
turtle.pendown() # okay in 2.6
* when you run Python 2.5, turtle will import, but there is no
turtle.pendown command. Instead, it is called turtle.down.
Documentation for 2.5:
https://docs.python.org/release/2.5.4/lib/module-turtle.html
Documentation for 2.6:
https://docs.python.org/release/2.6/library/turtle.html
--
Steve
More information about the Tutor
mailing list