Re: [Tutor] turtle on linux
I tried to import Tkinter and I got this message: Traceback (most recent call last): File "", line 1, in ImportError: No module named Tkinter And since I am running Linux, you may be under the false impression that I know what I am doing when it comes to using Linux. I have no idea what you mean by "package manager", so if you could enlighten me, that would be immensely appreciated. Thank you, Hershel On Fri, Jun 24, 2016 at 12:24 AM, Alan Gauld via Tutor <tutor@python.org> wrote: > On 24/06/16 01:21, Hershel Millman wrote: > > This is from my terminal on Fedora 24: > > > > [hmillman@localhost ~]$ python > > Python 2.7.10 (default, Sep 24 2015, 17:50:09) > > [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> import turtle > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: No module named turtle > > > > > > How do I solve this problem? > > This may be similar to the Mac issue in that you have a > non-Tk install. Try > > import Tkinter > > to see. > > The good news is that on Fedora you should be able to > upgrade to a Tkinter enabled Python 2.7 using your > package manager. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Fwd: : Turtle
Python didn't come installed on my Mac, my dad had to install it. I typed import Tkinter into the terminal and received no error message, and when I ran it in pycharm, I also received no error message. I found a little program online and ran it to test the functionality of Tkinter, and it worked. from Tkinter import * class Application(Frame): def say_hi(self): print "hi there, everyone!" def createWidgets(self): self.QUIT = Button(self) self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "red" self.QUIT["command"] = self.quit self.QUIT.pack({"side": "left"}) self.hi_there = Button(self) self.hi_there["text"] = "Hello", self.hi_there["command"] = self.say_hi self.hi_there.pack({"side": "left"}) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() root = Tk() app = Application(master=root) app.mainloop() root.destroy() and it finished with exit code 0. I just tried to use turtle in pycharm again, and for some reason it worked with exit code 0. I typed: from turtle import * speed('fastest') i = 0 while i < 1: forward(20) left(90) forward(20) left(90) forward(20) left(90) forward(20) left(91) i += 1 input() and it gave me no error message. However, when I typed the same thing, except instead of "from turtle import *", I typed "import turtle," I got this error message: /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 "/Users/Hershel/PycharmProjects/Project 1/notturtle.py" Traceback (most recent call last): File "/Users/Hershel/PycharmProjects/Project 1/notturtle.py", line 2, in speed('fastest') NameError: name 'speed' is not defined Process finished with exit code 1 How do I make it so pycharm is using python version 2.6 instead of 2.5? (I have python 2.6 in the same "versions" folder as 2.5) Thank you, Hershel -- Forwarded message -- From: *Alan Gauld via Tutor* <tutor@python.org> Date: Friday, June 24, 2016 Subject: [Tutor] Fwd: : Turtle To: tutor@python.org On 24/06/16 03:02, Hershel Millman wrote: > It tells me: > Trace back (most recent call last): > File "", line 1, in > NameError: name 'turtle' is not defined As I recall, the default install of Python on a Mac does not include Tkinter. Turtle uses Tkinter so I suspect turtle is not installed either. To confirm that try import Tkinter and see if that also gives an error. If I'm right you will need to ensure you use the 2.6 version for all your turtle stuff. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Fwd: : Turtle
When I try to use turtle in pycharm, it doesn't work, but when I try to use it in the terminal, it does work. Is it possible there is something wrong with my pycharm that is not letting it run properly? Thank you, Hershel -- Forwarded message -- From: *Joaquin Alzola* <joaquin.alz...@lebara.com> Date: Thursday, June 23, 2016 Subject: [Tutor] Fwd: : Turtle To: Hershel Millman <hers...@themillmans.net>, "tutor@python.org" < tutor@python.org> I tested with 2.6 and it works. >/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py" >Traceback (most recent call last): > File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", line 2, in > turtle.pendown() >AttributeError: 'module' object has no attribute 'pendown' Cannot access the documentation of the 2.5 to check if the pendown() is there. This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt. ___ Tutor maillist - Tutor@python.org <javascript:;> To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] turtle on linux
This is from my terminal on Fedora 24: [hmillman@localhost ~]$ python Python 2.7.10 (default, Sep 24 2015, 17:50:09) [GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import turtle Traceback (most recent call last): File "", line 1, in ImportError: No module named turtle How do I solve this problem? Thank you, Hershel ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Fwd: : Turtle
It tells me: Trace back (most recent call last): File "", line 1, in NameError: name 'turtle' is not defined Thanks! -- Forwarded message -- From: *Steven D'Aprano* <st...@pearwood.info> Date: Thursday, June 23, 2016 Subject: [Tutor] Fwd: : Turtle To: tutor@python.org 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 ___ Tutor maillist - Tutor@python.org <javascript:;> To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Fwd: : Turtle
Millman-Family-Admins-iMac-2:~ Hershel$ python Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import turtle >>> turtle.__file__ '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py' >>> turtle.pendown >>> turtle.pendown() >>> It seemed to work perfectly and do what it was supposed to. Is my problem then with PyCharm? Thanks. Begin forwarded message: > From: Alan Gauld via Tutor <tutor@python.org> > Date: June 23, 2016 4:44:15 PM MST > To: tutor@python.org > Subject: Re: [Tutor] Fwd: : Turtle > Reply-To: Alan Gauld <alan.ga...@yahoo.co.uk> > > On 23/06/16 22:13, Hershel Millman wrote: >> What I typed was: >> >> import turtle >> turtle.pendown() >> >> (And pendown was highlighted in pycharm, indicating that it was not a valid >> command.) > > Don't use pycharm. We need to eliminate as many variables as possible. > Start python in a Terminal and just type the commands into the raw > Python interpreter. Send a paste of the transcript. > I expect to see something like: > > agauld@ubuntu:~$ python2 > Python 2.7.6 (default, Jun 22 2015, 17:58:13) > [GCC 4.8.2] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import turtle >>>> turtle.__file__ > '/usr/lib/python2.7/lib-tk/turtle.pyc' >>>> turtle.pendown > >>>> turtle.pendown() >>>> > > Can you reproduce that on your Mac? (Except maybe with an > error message somewhere along the line?) > >> /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 >> "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py" >> Traceback (most recent call last): >> File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", >> line 2, in >>turtle.pendown() >> AttributeError: 'module' object has no attribute 'pendown' > > I notice that this says you are using Python 2.5 but your > last message suggested the module was in 2.6. > > I don't think that should make a difference for the turtle > module but it might be significant... Lets see your > transcript first. > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: : Turtle
What I typed was: import turtle turtle.pendown() (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 "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py" Traceback (most recent call last): File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", line 2, in turtle.pendown() AttributeError: 'module' object has no attribute 'pendown' Process finished with exit code 1 Thank you, Hershel Begin forwarded message: > From: Alan Gauld via Tutor <tutor@python.org> > Date: June 23, 2016 12:12:39 AM MST > To: tutor@python.org > Subject: Re: [Tutor] : Turtle > Reply-To: Alan Gauld <alan.ga...@yahoo.co.uk> > > On 23/06/16 01:52, Hershel Millman wrote: >> I found the turtle module on my computer. >> >>>>> import turtle >>>>> print(turtle.__file__) >> /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py > > That's the right turtle module do not rename it. > >>>> I entered "import turtle" instead of "from turtle import * ", but it >>>> looks as if it did not import the pendown command. Why is that? > > If that's the module you are importing it should work. > > What happens if you try: > >>>> import turtle >>>> turtle.pendown() > > Do you still get the error? > > If so can you cut n paste the entire session, including the initial > python startup message and the error message, into a mail for us? > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Fwd: Fwd: Turtle
I found the turtle module on my computer. >>> import turtle >>> print(turtle.__file__) /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/turtle.py I followed the chain of folders in my finder window, and was able to locate the file. I tried to rename the file and my computer told me I did not have the permissions to do so. When I searched my computer for another file named "turtle.py", I could not find one. What do I do? Thank you, Hershel Begin forwarded message: > From: Steven D'Aprano <st...@pearwood.info> > Date: June 19, 2016 6:24:29 PM MST > To: tutor@python.org > Subject: Re: [Tutor] Fwd: Fwd: Turtle > > On Sun, Jun 19, 2016 at 04:21:28PM -0700, Hershel Millman wrote: > >> I entered "import turtle" instead of "from turtle import * ", but it >> looks as if it did not import the pendown command. Why is that? > > Good question. > > Try this: > > import turtle > print(turtle.__file__) > > That should print something like > > '/usr/local/lib/python3.3/turtle.py' > > or wherever you have installed Python to. If it is something like this: > > /Users/Hershel/PycharmProjects/Project 1/turtle.py > > then you have (accidentally) saved a new file called "turtle.py" and it > is shadowing the standard library file and blocking it from being > loading. Instead of importing the real turtle module, Python is > importing your fake turtle module. > > To fix that, delete or rename your turtle.py module, quit PyCharm, and > start it up again. > > Then you'll need to fix a small bug in your code: > >> import turtle >> >> def drawSquare(size=100): >>turtle.pendown > > Add round brackets (parentheses) to the pendown: > >turtle.pendown() > > Without the brackets, it just names the function, it doesn't call it. In > your case, it probably doesn't matter, since the turtle starts with the > pen down by default. > > > > -- > Steve > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Fwd: Turtle
I entered "import turtle" instead of "from turtle import * ", but it looks as if it did not import the pendown command. Why is that? import turtle def drawSquare(size=100): turtle.pendown turtle.forward(size) turtle.left(90) turtle.forward(size) turtle.left(90) turtle.forward(size) turtle.left(90) turtle.forward(size) turtle.left(90) drawSquare(50) input () Traceback (most recent call last): File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", line 14, in drawSquare(50) File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", line 4, in drawSquare turtle.pendown AttributeError: 'module' object has no attribute 'pendown' Process finished with exit code 1 Begin forwarded message: > From: Alan Gauld via Tutor <tutor@python.org> > Date: June 19, 2016 1:47:44 AM MST > To: tutor@python.org > Subject: Re: [Tutor] Fwd: Turtle > Reply-To: Alan Gauld <alan.ga...@yahoo.co.uk> > > On 19/06/16 04:46, Hershel Millman wrote: > >>> In pycharm, when I enter the following, it replies with the following error >>> message: >>> >>> from turtle import * >>> > > Change that to > > import turtle > > and it should work. > > > >>> def drawSquare(size=100): >>> turtle.pendown() >>> turtle.forward(size) >>> turtle.left(90) >>> turtle.forward(size) >>> turtle.left(90) >>> turtle.forward(size) >>> turtle.left(90) >>> turtle.forward(size) >>> turtle.left(90) >>> >>> drawSquare(50) >>> >>> input () > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Turtle
Begin forwarded message: > From: Hershel Millman <hers...@themillmans.net> > Date: June 18, 2016 2:39:21 PM MST > To: Steven D'Aprano <st...@pearwood.info> > Subject: Re: [Tutor] Turtle > > Steven, > > I followed your instruction and typed "import turtle" into the terminal on my > mac, and nothing happened. > > When I entered the following, a new window was created in which the turtle > behaved exactly like it was supposed to. > > for i in range(4): > ...turtle.right(90) > ...turtle.forward(200) > > In pycharm, when I enter the following, it replies with the following error > message: > > from turtle import * > > def drawSquare(size=100): >turtle.pendown() >turtle.forward(size) >turtle.left(90) >turtle.forward(size) >turtle.left(90) >turtle.forward(size) >turtle.left(90) >turtle.forward(size) >turtle.left(90) > > drawSquare(50) > > input () > > Traceback (most recent call last): > File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", > line 14, in >drawSquare(50) > File "/Users/Hershel/PycharmProjects/Project 1/practicefornotturtle.py", > line 4, in drawSquare >turtle.pendown() > NameError: global name 'turtle' is not defined > > Process finished with exit code 1 > > Thank you, > > Hershel > > On Jun 18, 2016, at 2:00 AM, Steven D'Aprano wrote: > >> On Fri, Jun 17, 2016 at 11:25:40PM -0700, Hershel Millman wrote: >>> Hello tutors, >>> >>> I have been learning basic python on my Macintosh computer and >>> everything I have tried so far has worked, except when I tried to use >>> the turtle module. I then used my Linux computer and the turtle module >>> still did not work. >> >> What does "did not work" mean? >> >> Did you get an error message? Blue Screen Of Death? Computer caught >> fire? >> >> I see later on that you are running PyCharm. Let's try this with the >> default Python interpreter. Open a terminal window. You should see a >> prompt ending with a dollar sign $ e.g. on my computer I see: >> >> [steve@ando ~]$ >> >> Type the command "python" without quotes, and hit Enter. You should get >> a message about the version of Python you are running, and a >>> prompt. >> This is the Python interpreter. Now enter: >> >> import turtle >> >> What happens? Do you get an error? >> >> If not, what happens if you enter these lines? >> >> turtle.shape('turtle') >> for i in range(4): >> turtle.right(90) >> turtle.forward(200) >> >> (Hit the TAB key at the beginning of the last two lines to get the >> indent. When you have finished typing, you will need to enter one extra >> time to have Python run the code.) >> >> Describe what happens. Do you get an error? If you do, copy and paste >> the ENTIRE error message, starting with the line "Traceback". >> >> >> >>> I tried to use the command line and type "sudo dnf >>> install turtle", "sudo pip install turtle", and it told me "no package >>> turtle available". >> >> That's because turtle is part of the standard library. It's already >> installed. If you run: >> >> locate turtle.py >> >> from your Linux or Mac OS X shell (not from Python!) you should see a >> list of at least one turtle.py files. >> >> >>> I tried to install Python-tk and python3-tk, and I >>> was told that no packages by those names were available. I also tried >>> reinstalling python 2 and python 3, to no avail. >> >> Reinstalling Python should be the *last* resort, not the first, or >> second. >> >> >> >> -- >> Steve >> ___ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Turtle
Hello tutors, I have been learning basic python on my Macintosh computer and everything I have tried so far has worked, except when I tried to use the turtle module. I then used my Linux computer and the turtle module still did not work. I tried to use the command line and type "sudo dnf install turtle", "sudo pip install turtle", and it told me "no package turtle available". I tried to install Python-tk and python3-tk, and I was told that no packages by those names were available. I also tried reinstalling python 2 and python 3, to no avail. I am running Python 2.7.1 using Mac OS X 10.6.8 on an iMac, Python 3.5.1 using Mac OS X 10.10.5, and the default python2 and Python3 that comes with fedora 24. On my Mac running Python 3, I have tried about 6 times to enter the command import turtle, and nothing has happened. However, on my most recent attempt, I changed nothing about the program and hit run, and for some reason it worked. All of the terms were still underlined in my pycharm window, and it told me that the commands were not found, and implied that they should not be working. However, after exiting pycharm, and reopening it, it worked again, even though it told me the commands were not valid. My question about running Python 3 on my Mac running 10.10.5: What do I need to do to make it so my computer recognizes that they are valid commands? My questions about running python 2.7 on my Mac running 10.6.8 and my computer running Python 2 and 3 on fedora 24: What do I have to do to get the turtle module? And once I have it, how do I use it? Thank you, Hershel ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor