[Tutor] GNUPLOT
Hi Hoping that someone can help me here. I have been reading about gnuplot and it's plotting functionality, so i decided to install this: I downloaded the gnuplot windows function and then installed the gnuplot.py file using the setut.py and install command all worked. I also installed the numeric python. I start by a simple example below and then I get stuck... >>> import Gnuplot, Gnuplot.funcutils >>> from Numeric import * >>> g = Gnuplot.Gnuplot() >>> g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) Traceback (most recent call last): File "", line 1, in -toplevel- g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 274, in plot self.refresh() File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 215, in refresh self(self.plotcmd + ' ' + string.join(plotcmds, ', ')) File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 199, in __call__ self.gnuplot(s) File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py", line 125, in __call__ self.write(s + '\n') IOError: [Errno 22] Invalid argument Has someone experienced the same issue above if so did you manage to overcome it? Much appreciated if someone can help solve this issue for me. Thanks Ray ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Weird import problem with PythonIDE on Mac (was 'import problem')
Is it possible that the script is not running as __main__? Add print __name__ to the script and see what it says... Kent Chris Smith wrote: On Tuesday, Apr 19, 2005, Lee Cullens wrote: I assume you mean PythonIDE for Python 2.3 (I usually use 2.4 and WingIDE). Here it is (indents screwed up with var font): HTH, Lee C import timeit def y1(): print ’y1 executed’ def y2(): print ’y2 executed’ for f in [y1,y2]: name = f.__name__ print name; f() t=timeit.Timer(’%s()’ % name, ’from __main__ import %s’ % name) print t.timeit(1) I wrote this yesterday -- Well, how bizarre! Now I run the code again (after having restarted the PythonIDE) and now I can't get it to NOT work. And it previously had not run for many tries. I don't suppose this is some sort of quantum effect ;-) Oh well, I'll keep my eyes open to see if this happens again. -- And now today, the problem is back again :-( What's going on? Here is a smaller code: ### def y1(): print 'y1 executed' for f in [y1]: name = f.__name__ f() s1 = '%s()' % name s2 = 'from __main__ import %s' % name t=timeit.Timer(s1, s2) print t.timeit(1) ### Here is the full report from the traceback window {it's great to be able to cut and paste from that window, thanks Just} ''' ImportError: cannot import name y1 Traceback (innermost last) File "", line 10, in ? File "timeit.py", line 158, in timeit return self.inner(it, self.timer) File "", line 3, in inner ''' ** If I click on the edit button it says that cannot be found. Is this an error to pay attention to or is that an unrelated problem of trying to browse a (perhaps compiled) source file? Here is what I've tried to reproduce the problem: 1) I have restarted the system (10.2.8) and run nothing but this script and still get the error. 2) removed my PythonStartup and sitecustomize.py codes after quitting; problem still persists 3) re-installed MacPython 2.3.3 after moving the old version's macPython 2.3.3 folder to the desktop 4) I have tried running the script in the add with and without the "run as __main__" option. I DO NOT have the error show up when I run the script through the Terminal (i.e. %python timeitproblem.py). I also DO NOT have the problem if I run the script with PyOXIDE. As noted yesterday, there are some unknown steps that make the problem go away, though I do not know what these are yet. Does anyone else have any insights? /c ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] GNUPLOT
Strange. This example works for me on Win2K with Python 2.4. Kent [EMAIL PROTECTED] wrote: Hi Hoping that someone can help me here. I have been reading about gnuplot and it's plotting functionality, so i decided to install this: I downloaded the gnuplot windows function and then installed the gnuplot.py file using the setut.py and install command all worked. I also installed the numeric python. I start by a simple example below and then I get stuck... import Gnuplot, Gnuplot.funcutils from Numeric import * g = Gnuplot.Gnuplot() g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) Traceback (most recent call last): File "", line 1, in -toplevel- g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 274, in plot self.refresh() File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 215, in refresh self(self.plotcmd + ' ' + string.join(plotcmds, ', ')) File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 199, in __call__ self.gnuplot(s) File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py", line 125, in __call__ self.write(s + '\n') IOError: [Errno 22] Invalid argument Has someone experienced the same issue above if so did you manage to overcome it? Much appreciated if someone can help solve this issue for me. Thanks Ray ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Error Raising (Joseph Q.)
(here I go again?) Where could I find a nice long list of the errors I can raise? (I mean like EOF errors when some one doesn't fill in their name when they're supposed to). Thanks, Joe ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Error Raising (Joseph Q.)
Joseph Quigley wrote: (here I go again?) Where could I find a nice long list of the errors I can raise? (I mean like EOF errors when some one doesn't fill in their name when they're supposed to). The standard (built-in) exceptions are documented here: http://docs.python.org/lib/module-exceptions.html If you don't find any that suit you, defining your own is as easy as class MyException(Exception): pass try: raise MyException except MyException: ... Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score)
Hi Sorry about that, I'm using Python 2.3.4 cause when Python 2.4 was released there wasn't libraries like MySQLdb and ReportLab (and I needed those) I agree with Max, the problem is somewhere else but it'll take time (I don't have to do a report but I do have to finish a web-based system over Linux) In the mean time only have to say that your game rocks!! I'll send you mine next week Regards Alberto http://graphics.hotmail.com/emvamp.gif"; width=12> Gaucho From: "D. Hartley" <[EMAIL PROTECTED]> Reply-To: "D. Hartley" <[EMAIL PROTECTED]> To: Alberto Troiano <[EMAIL PROTECTED]> Subject: Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score) Date: Wed, 20 Apr 2005 16:10:02 -0700 Alberto, The sorting works just fine on mine (and on my friends' computers too). sort CAN take no arguments, but it can also take three - key, cmp, and reverse. Perhaps you have an older version of something? ~Denise On 4/20/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: > Hi > > The thing is this > > I get an error that says sort() has no arguments > > Th error is in the sentence > high_score.sort(reverse=TRUE) > > If you put just sort() it will work but the list will show from low to high > and we don't want that 'cause if you make a high score it won't be able to > know so you have to figure out another way to reverse the list > > Regards > > Alberto > >From: "D. Hartley" <[EMAIL PROTECTED]> > >Reply-To: "D. Hartley" <[EMAIL PROTECTED]> > >To: Alberto Troiano <[EMAIL PROTECTED]> > >Subject: Re: [Tutor] crash - switching between text window and > >graphics/gamewindow (high score) > >Date: Wed, 20 Apr 2005 14:22:24 -0700 > > > >Alberto, > > > >Thank you for replying! I sent answers to the general questions to the > >tutor list, so that hopefully the extra clarification might help > >someone else answer (I havent had much luck with this thread, > >unfortunately). But I wanted to reply to you personally to send a > >copy of the game. It's a "mod" of a game from pygame, but I've added > >a lot of stuff to it. I'll send it as a zip file with two different > >"play" files - run the one simply called "play" to test out the game > >without the crash (oh, a side-note: the enemy ships will change > >graphics on levels 2 and 3, but they're not pretty - i just put those > >graphics in there as a place holder until i make their prettier > >replacements). Anyway, the play file called "copy of play > >wscorelist2" is the copy with the scorelist that is crashing. If you > >just want to see the *code* you can look at either of those two > >files, but I thought you might want to play the actual game so I'm > >sending it all. Have fun :) Any comments/ideas/suggestions are very > >welcomed!! I'm having a couple friends test it out. But since I'm new > >I might not be able to take ALL of the suggestions before I have to > >have the game done next week, ha ha. > > > >Anyway thanks so much for replying, and for any help or suggestions > >you might have about the crash. > > > >~Denise > > > >P.S. if you dont have them, you'll need pygame and the livewires > >module, available at http://www.livewires.org.uk/python/lwpackage.html > >. Thanks again! > > > >On 4/20/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: > > > Hey > > > > > > I'm curious > > > > > > What extension are you using on your game??? > > > is it .py??? > > > > > > And what OS are you running the game??? > > > > > > Another thing. I made a space ship game to learn Python. Is there a > > > possibility that we exchange the games so we can know differents points > >of > > > view > > > > > > I'll wait your reply > > > > > > Regards > > > > > > Alberto > > > > > > >From: "D. Hartley" <[EMAIL PROTECTED]> > > > >Reply-To: "D. Hartley" <[EMAIL PROTECTED]> > > > >To: Python tutor > > > >Subject: [Tutor] crash - switching between text window and > > > >graphics/gamewindow (high score) > > > >Date: Tue, 19 Apr 2005 15:29:42 -0700 > > > > > > > >Ok. I got in the working code to have a high score list, and it even > > > >saves/loads one now (!!). The only problem is, clicking back from the > > > >text window to the game window (only after you entered in your name to > > > >go onto the high score list), closes the program. you dont get to say > > > >y/n to another game, it just shuts down. i cant run a debugger on it, > > > >because the error doesnt happen when I F5-run the game from the python > > > >IDLE script, only when i have ran it by doubleclicking on it (which is > > > >how you're supposed to run it. otherwise it doesnt shut down > > > >properly). i really really REALLY want to keep the high score part of > > > >my program, because i worked really hard to get this to work. but i > > > >have to have this program running with NO crashes in like a week (it's > > > >a birthday present, and the birthday is approaching fast!) > > > > > > > >Here's the "end of game" code: > > > > > > > > #g
Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score)
Hi Sorry about that, I'm using Python 2.3.4 cause when Python 2.4 was released there wasn't libraries like MySQLdb and ReportLab (and I needed those) I agree with Max, the problem is somewhere else but it'll take time (I don't have to do a report but I do have to finish a web-based system over Linux) In the mean time only have to say that your game rocks!! I'll send you mine next week Regards Alberto http://graphics.hotmail.com/emvamp.gif"; width=12> Gaucho From: "D. Hartley" <[EMAIL PROTECTED]> Reply-To: "D. Hartley" <[EMAIL PROTECTED]> To: Alberto Troiano <[EMAIL PROTECTED]> Subject: Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score) Date: Wed, 20 Apr 2005 16:10:02 -0700 Alberto, The sorting works just fine on mine (and on my friends' computers too). sort CAN take no arguments, but it can also take three - key, cmp, and reverse. Perhaps you have an older version of something? ~Denise On 4/20/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: > Hi > > The thing is this > > I get an error that says sort() has no arguments > > Th error is in the sentence > high_score.sort(reverse=TRUE) > > If you put just sort() it will work but the list will show from low to high > and we don't want that 'cause if you make a high score it won't be able to > know so you have to figure out another way to reverse the list > > Regards > > Alberto > >From: "D. Hartley" <[EMAIL PROTECTED]> > >Reply-To: "D. Hartley" <[EMAIL PROTECTED]> > >To: Alberto Troiano <[EMAIL PROTECTED]> > >Subject: Re: [Tutor] crash - switching between text window and > >graphics/gamewindow (high score) > >Date: Wed, 20 Apr 2005 14:22:24 -0700 > > > >Alberto, > > > >Thank you for replying! I sent answers to the general questions to the > >tutor list, so that hopefully the extra clarification might help > >someone else answer (I havent had much luck with this thread, > >unfortunately). But I wanted to reply to you personally to send a > >copy of the game. It's a "mod" of a game from pygame, but I've added > >a lot of stuff to it. I'll send it as a zip file with two different > >"play" files - run the one simply called "play" to test out the game > >without the crash (oh, a side-note: the enemy ships will change > >graphics on levels 2 and 3, but they're not pretty - i just put those > >graphics in there as a place holder until i make their prettier > >replacements). Anyway, the play file called "copy of play > >wscorelist2" is the copy with the scorelist that is crashing. If you > >just want to see the *code* you can look at either of those two > >files, but I thought you might want to play the actual game so I'm > >sending it all. Have fun :) Any comments/ideas/suggestions are very > >welcomed!! I'm having a couple friends test it out. But since I'm new > >I might not be able to take ALL of the suggestions before I have to > >have the game done next week, ha ha. > > > >Anyway thanks so much for replying, and for any help or suggestions > >you might have about the crash. > > > >~Denise > > > >P.S. if you dont have them, you'll need pygame and the livewires > >module, available at http://www.livewires.org.uk/python/lwpackage.html > >. Thanks again! > > > >On 4/20/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: > > > Hey > > > > > > I'm curious > > > > > > What extension are you using on your game??? > > > is it .py??? > > > > > > And what OS are you running the game??? > > > > > > Another thing. I made a space ship game to learn Python. Is there a > > > possibility that we exchange the games so we can know differents points > >of > > > view > > > > > > I'll wait your reply > > > > > > Regards > > > > > > Alberto > > > > > > >From: "D. Hartley" <[EMAIL PROTECTED]> > > > >Reply-To: "D. Hartley" <[EMAIL PROTECTED]> > > > >To: Python tutor > > > >Subject: [Tutor] crash - switching between text window and > > > >graphics/gamewindow (high score) > > > >Date: Tue, 19 Apr 2005 15:29:42 -0700 > > > > > > > >Ok. I got in the working code to have a high score list, and it even > > > >saves/loads one now (!!). The only problem is, clicking back from the > > > >text window to the game window (only after you entered in your name to > > > >go onto the high score list), closes the program. you dont get to say > > > >y/n to another game, it just shuts down. i cant run a debugger on it, > > > >because the error doesnt happen when I F5-run the game from the python > > > >IDLE script, only when i have ran it by doubleclicking on it (which is > > > >how you're supposed to run it. otherwise it doesnt shut down > > > >properly). i really really REALLY want to keep the high score part of > > > >my program, because i worked really hard to get this to work. but i > > > >have to have this program running with NO crashes in like a week (it's > > > >a birthday present, and the birthday is approaching fast!) > > > > > > > >Here's the "end of game" code: > > > > > > > > #g
Fwd: [Tutor] crash - switching between text window and graphics/gamewindow (high score)
Thanks for the encouragement!! I'm going to be completing some further updates today and hope to post a url where anyone can get the whole game and try it out. I made a fall-back version where the game displays not a high score list requiring input in the text window, but only keeps track of the one highest score and displays that (i.e., no names = no user input into the console window = no crash). That way if I can't find an answer to the crash problem by next Thursday (holy crap, only one week), I'll still have a working game I can give to him. I'll let you guys know if I find anything, and will post the url as soon as the game is uploaded. And let me know if any ideas come to you about the crash! Thanks, Denise -- Forwarded message -- From: Alberto Troiano <[EMAIL PROTECTED]> Date: Apr 21, 2005 6:21 AM Subject: Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score) To: [EMAIL PROTECTED] Cc: tutor@python.org Hi Sorry about that, I'm using Python 2.3.4 cause when Python 2.4 was released there wasn't libraries like MySQLdb and ReportLab (and I needed those) I agree with Max, the problem is somewhere else but it'll take time (I don't have to do a report but I do have to finish a web-based system over Linux) In the mean time only have to say that your game rocks!! I'll send you mine next week Regards Alberto http://graphics.hotmail.com/emvamp.gif"; width=12>Gaucho >From: "D. Hartley" <[EMAIL PROTECTED]> >Reply-To: "D. Hartley" <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >Subject: Re: [Tutor] crash - switching between text window and >graphics/gamewindow (high score) >Date: Wed, 20 Apr 2005 16:10:02 -0700 > >Alberto, > >The sorting works just fine on mine (and on my friends' computers >too). sort CAN take no arguments, but it can also take three - key, >cmp, and reverse. Perhaps you have an older version of something? > >~Denise > >On 4/20/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: > > Hi > > > > The thing is this > > > > I get an error that says sort() has no arguments > > > > Th error is in the sentence > > high_score.sort(reverse=TRUE) > > > > If you put just sort() it will work but the list will show from low to >high > > and we don't want that 'cause if you make a high score it won't be able >to > > know so you have to figure out another way to reverse the list > > > > Regards > > > > Alberto > > >From: "D. Hartley" <[EMAIL PROTECTED]> > > >Reply-To: "D. Hartley" <[EMAIL PROTECTED]> > > >To: Alberto Troiano <[EMAIL PROTECTED]> > > >Subject: Re: [Tutor] crash - switching between text window and > > >graphics/gamewindow (high score) > > >Date: Wed, 20 Apr 2005 14:22:24 -0700 > > > > > >Alberto, > > > > > >Thank you for replying! I sent answers to the general questions to the > > >tutor list, so that hopefully the extra clarification might help > > >someone else answer (I havent had much luck with this thread, > > >unfortunately). But I wanted to reply to you personally to send a > > >copy of the game. It's a "mod" of a game from pygame, but I've added > > >a lot of stuff to it. I'll send it as a zip file with two different > > >"play" files - run the one simply called "play" to test out the game > > >without the crash (oh, a side-note: the enemy ships will change > > >graphics on levels 2 and 3, but they're not pretty - i just put those > > >graphics in there as a place holder until i make their prettier > > >replacements). Anyway, the play file called "copy of play > > >wscorelist2" is the copy with the scorelist that is crashing. If you > > >just want to see the *code* you can look at either of those two > > >files, but I thought you might want to play the actual game so I'm > > >sending it all. Have fun :) Any comments/ideas/suggestions are very > > >welcomed!! I'm having a couple friends test it out. But since I'm new > > >I might not be able to take ALL of the suggestions before I have to > > >have the game done next week, ha ha. > > > > > >Anyway thanks so much for replying, and for any help or suggestions > > >you might have about the crash. > > > > > >~Denise > > > > > >P.S. if you dont have them, you'll need pygame and the livewires > > >module, available at http://www.livewires.org.uk/python/lwpackage.html > > >. Thanks again! > > > > > >On 4/20/05, Alberto Troiano <[EMAIL PROTECTED]> wrote: > > > > Hey > > > > > > > > I'm curious > > > > > > > > What extension are you using on your game??? > > > > is it .py??? > > > > > > > > And what OS are you running the game??? > > > > > > > > Another thing. I made a space ship game to learn Python. Is there a > > > > possibility that we exchange the games so we can know differents >points > > >of > > > > view > > > > > > > > I'll wait your reply > > > > > > > > Regards > > > > > > > > Alberto > > > > > > > > >From: "D. Hartley" <[EMAIL PROTECTED]> > > > > >Reply-To: "D. Hartley" <[EMAIL PROTECTED]> > > > > >To: Python tutor
Re: [Tutor] Installation Routines (Joseph Quigley)
Rpm does in fact have dependency resolution, and rpm-based distributions use a package manager that can download the dependencies and install them for you - urpmi on mandrake, yum or apt4rpm on Fedora and Redhat, Yast on Suse I've used all of these, they are all rpm based, and they all install dependencies. If you use the raw "rpm" command, even that will tell you "missing dependecy foo". That being said, apt-get on debian is still my favorite (for sheer number of available packages), but urpmi on mandrake or Yast on Suse are quite excellent. -Jay On Wednesday 20 April 2005 04:17 pm, Max Noel wrote: emerge and apt-get come to mind. rpm is inferior (no dependency > resolution) but still does a good job, and I hear autopackage isn't > bad. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] trouble setting the environment
All, I have program and init I want to "source" a .ksh file to set some environment variables and then use those variables in my program. Is this possible? I vaguely remember something about the system env and the interpreters env being separate after the interpreter starts up. For instance if I have a .ksh file called envSet.ksh: #!/bin/ksh unset OPSBIN export OPSBIN=/u/ops/bin ---end -- Then >>> os.system(". envSet.ksh") 0 >>> os.getenv("OPSBIN") >>> What is the 0. I know that I can set the env using Python but all of the correct env are in the .ksh files maintained by others. I would hate to have to take the .ksh and tread each line and if it is an export turn that into a python os.environ statement. Any ideas. Thanks John ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] GNUPLOT
[Kent] > Strange. This example works for me on Win2K with Python 2.4. [Ray] > > Hoping that someone can help me here. I have been reading about > > gnuplot and it's plotting functionality, so i decided to install this: > > I downloaded the gnuplot windows function and then installed the > > gnuplot.py file using the setut.py and install command all worked. I > > also installed the numeric python. [some error text cut] > > Traceback (most recent call last): > > File "", line 1, in -toplevel- > > g.plot([[0,1.1], [1,5.8], [2,3.3], [3,4.2]]) > > File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 274, in > > plot > > self.refresh() > > File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 215, in > > refresh > > self(self.plotcmd + ' ' + string.join(plotcmds, ', ')) > > File "C:\Python23\Lib\site-packages\Gnuplot\_Gnuplot.py", line 199, in > > __call__ > > self.gnuplot(s) > > File "C:\Python23\Lib\site-packages\Gnuplot\gp_win32.py", line 125, in > > __call__ > > self.write(s + '\n') > > IOError: [Errno 22] Invalid argument > > > > Has someone experienced the same issue above if so did you manage to > > overcome it? Hi Ray, Yeah, it looks like Joshua Pollack ran into this issue three years ago: http://mail.python.org/pipermail/tutor/2002-September/017579.html I'm going through the archive now to see if he was able to resolve the problem ok. You might also want to bring this up on the gnuplot-py-users mailing list: I'm sure that they'd definitely know what was going on: http://lists.sourceforge.net/lists/listinfo/gnuplot-py-users In the meantime, I'll continue to do some hunting in the mail archive. *grin* Good luck to you! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] GNUPLOT
> Yeah, it looks like Joshua Pollack ran into this issue three years ago: > > http://mail.python.org/pipermail/tutor/2002-September/017579.html > > I'm going through the archive now to see if he was able to resolve the > problem ok. Hi Ray, Yikes, it looks like someone never really answered Joshua when he brought up that question. Ugh. Let's fix this now. My best guess right now is that the module can't find the gnuplot command. 'gp_win32' uses the popen() command to try to connect to the underlying gnuplot engine, and if it's given a command that it doesn't know about, we'll get the same kind of errors that you're seeing: ### >>> import os >>> test = os.popen("foobar", "w") >>> sh: line 1: foobar: command not found >>> ### It's a bit disappointing that Python doesn't raise an exception at this point. I wonder if that can be fixed. Anyway, after this point, all bets are off, and even if 'test' is some kind of object, it doesn't behave well at all: ### >>> test >>> test.write("hello world") >>> test.flush() Traceback (most recent call last): File "", line 1, in ? IOError: [Errno 32] Broken pipe ### I'm on a Unix system, so the exact error looks a bit different from yours, but I think that the fundamental problem is the same: the module will emit exceptions when it actually starts to try talking to gnuplot, rather than at the point of initialization. It makes for a slightly confusing error message situation, since the error about not finding gnuplot should have been reported earlier. By default, gp_win32.py tries to use the command 'pgnuplot.exe' as the gnuplot command: ## (Within gp_win32.py) gnuplot_command = r'pgnuplot.exe' ## So check to see if you can access the command 'pgnuplot.exe' from your command line from anywhere. If not, then that's the problem, and you'll probably want to put pgnuplot.exe in your PATH somewhere. Either that, or manually munge up gp_win32.py so that it explicitely points to the pgnuplot.exe binary with its full path. You might not have pgnuplot.exe if you're running an older version of Gnuplot. Do you know what version of Gnuplot you have? If you have one whose version is < 3.7.1, then you probably need to grab pgnuplot.exe from the gnuplot FTP site here: ftp://ftp.gnuplot.info/pub/gnuplot/testing/windows-stdin.zip (Taken from the README.txt in the Python gnuplot module.) But since that file is just C source code, it might just be best to make sure you're running the latest version of Gnuplot, since it should include pgnuplot.exe now. If you have any questions, please feel free to ask. I hope this helps! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: Error Raising
Ahh. I really like the ability to make my own exceptions. This info will help alot. Thanks, Joe PS. Would the Tutorial included with IDLE be the same as the site's docs? The standard (built-in) exceptions are documented here: http://docs.python.org/lib/module-exceptions.html If you don't find any that suit you, defining your own is as easy as class MyException(Exception): pass try: raise MyException except MyException: ... Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] GNUPLOT
[EMAIL PROTECTED] wrote: Hi I have also now tried this on version 2.4 and w2k.no luck. Anything special with installing gnuplot or just extracting it and running the .exe.. No, nothing special that I remember. This thread on c.l.python has a suggestion at the end that might help: http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/523e2e6af79281af/67f29c3f09058a10?rnum=2&hl=en#67f29c3f09058a10 This thread suggests to make sure the executable is in your PATH environment variable: http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/bcc75878335bf571/49322acb8520f46f?hl=en#49322acb8520f46f Actually they are both suggesting the same thing, that the exe is not being found. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] trouble setting the environment
Ertl, John wrote: All, I have program and init I want to "source" a .ksh file to set some environment variables and then use those variables in my program. Is this possible? I vaguely remember something about the system env and the interpreters env being separate after the interpreter starts up. What about making a shell file that sources your ksh file, then starts python? Kent For instance if I have a .ksh file called envSet.ksh: #!/bin/ksh unset OPSBIN export OPSBIN=/u/ops/bin ---end -- Then os.system(". envSet.ksh") 0 os.getenv("OPSBIN") What is the 0. I know that I can set the env using Python but all of the correct env are in the .ksh files maintained by others. I would hate to have to take the .ksh and tread each line and if it is an export turn that into a python os.environ statement. Any ideas. Thanks John ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Re: Error Raising
Joseph Quigley wrote: PS. Would the Tutorial included with IDLE be the same as the site's docs? Yes, I think so, though the site docs might be slightly newer, they are updated occasionally. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] trouble setting the environment
Kent, Good idea except that the environment that needs to be set depends on the answers to some of the input that I get in the Python program. Nothing is ever easy here. Thanks for the ideas. John Ertl -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: Thursday, April 21, 2005 13:20 Cc: tutor@python.org Subject: Re: [Tutor] trouble setting the environment Ertl, John wrote: > All, > > I have program and init I want to "source" a .ksh file to set some > environment variables and then use those variables in my program. > > Is this possible? I vaguely remember something about the system env and the > interpreters env being separate after the interpreter starts up. What about making a shell file that sources your ksh file, then starts python? Kent > > For instance if I have a .ksh file called envSet.ksh: > > #!/bin/ksh > > unset OPSBIN > > export OPSBIN=/u/ops/bin > > ---end -- > > Then > > os.system(". envSet.ksh") > > 0 > os.getenv("OPSBIN") > > > What is the 0. I know that I can set the env using Python but all of the > correct env are in the .ksh files maintained by others. I would hate to > have to take the .ksh and tread each line and if it is an export turn that > into a python os.environ statement. > > Any ideas. > > Thanks > > John > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] TKinter and things over Linux
Hey all Thanks for all your help. I solved the problem by installing ALL the packages of Red Hat 9.0 so basically I have 5 GB of OS in my HD haha :D I must something you said about the development libraries but I really don't have time to find out which one so I install them all Thanks again and sorry for the troubles I may had cause Best regards Alberto From: "R. Alan Monroe" <[EMAIL PROTECTED]> Reply-To: "R. Alan Monroe" <[EMAIL PROTECTED]> To: Tutor Python Subject: Re: [Tutor] TKinter and things over Linux Date: Wed, 20 Apr 2005 19:53:21 -0400 > apt-get and yum are available for Redhat style releases. They will > download and install packages and figure out the dependency issues. > (yum is written in Python so this is slightly on topic.) Gentoo's "emerge" system is also written in Python. Alan ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] trouble setting the environment
Ertl, John wrote: Kent, Good idea except that the environment that needs to be set depends on the answers to some of the input that I get in the Python program. Nothing is ever easy here. Maybe you could write a Python program that asks the questions, then spawns a shell task which sets the correct environment and runs another Python program that does the rest of the work? Or, a ksh wrapper that sources the right program then outputs its environment to a .py file that you can import to get the config? Just don't give me credit for the idea, I don't want to have anything to do with it :-) Kent -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: Thursday, April 21, 2005 13:20 Cc: tutor@python.org Subject: Re: [Tutor] trouble setting the environment Ertl, John wrote: All, I have program and init I want to "source" a .ksh file to set some environment variables and then use those variables in my program. Is this possible? I vaguely remember something about the system env and the interpreters env being separate after the interpreter starts up. What about making a shell file that sources your ksh file, then starts python? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Installation Routines (Joseph Quigley)
> Then again, how many free installers are there for linux? The two most common are Red Hat's Package Manager (rpm) and the GNU apt-get system. But other distros also have install systems and so far as I know they are all free. But OTOH its also much easier to write a Unix installer since it simply involves copying files to some standard places and editing some plain text files. There are some commercial installers that will target Windows and Linux from the same basic setup data. But I've never used them so can't comment on how well they work! Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] trouble setting the environment
Kent, Like you allude ...a bit too much "what the heck is that" going on. I will give a few other things a try...I may just have to have the program run and get the info then stop and have the user source the correct .ksh then run another py program. (basically the same thing but manually). Thanks, John Ertl -Original Message- From: Kent Johnson [mailto:[EMAIL PROTECTED] Sent: Thursday, April 21, 2005 13:49 Cc: tutor@python.org Subject: Re: [Tutor] trouble setting the environment Ertl, John wrote: > Kent, > > Good idea except that the environment that needs to be set depends on the > answers to some of the input that I get in the Python program. Nothing is > ever easy here. Maybe you could write a Python program that asks the questions, then spawns a shell task which sets the correct environment and runs another Python program that does the rest of the work? Or, a ksh wrapper that sources the right program then outputs its environment to a .py file that you can import to get the config? Just don't give me credit for the idea, I don't want to have anything to do with it :-) Kent > -Original Message- > From: Kent Johnson [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 21, 2005 13:20 > Cc: tutor@python.org > Subject: Re: [Tutor] trouble setting the environment > > Ertl, John wrote: > >>All, >> >>I have program and init I want to "source" a .ksh file to set some >>environment variables and then use those variables in my program. >> >>Is this possible? I vaguely remember something about the system env and > > the > >>interpreters env being separate after the interpreter starts up. > > > What about making a shell file that sources your ksh file, then starts > python? > > Kent > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Dynamically composing a module name
> Inside of the setup() function, a call to the cgi object determines > the name of the calling application (form1,py ... etc.) and > then imports another module (automatically generated from another > process), always having the same members, composing that auto module > name from the name of the calling application: form1.py => > form1_extra.py.. And if I have to change the algorithm that > determines the name of the module imported or the names of the > members of the modules, I could just do it in two places: > the setup() function and the application generating the auto modules > (which isn't necessarily written in python). This sounds to me like a description of an object oriented design using inheritance and polymorphism. An abstract class that defines a standard set of methods that are called in a generic way which may be substituted at runtime by any one of a number of subclasses each implementing their own specialised version of the generic behaviour. The snag with importing at point of use is that importing a newly created module is one of the slowest things you an do in Python - it has to compile it and then read it and then execute it! If you can load the moules in advance somehow (maybe in a thread?) there might be significant gains... Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to obfuscate a database password. (fwd)
> I am not necessarily talking about passwords for users but about the > password that is used for connecting to the database. In a compiled > language you would have to look pretty hard in a dll to find where the > password had been encoded. IT would be insanely bad practice to embed the password in the code, compiled or not. (And in fact its very easy to strip all the strings out of a compiled executable - the strings command on unix does exactly that...) BUt the real problem is that if the database gets hacked the database administrator can't change the pasword unless he can also edit the application source code and rebuild it! It is normal practice to have the password stored in a text file (that may be encrypted) and read it on startup of the program, or better still to pass the login details(username and password) in as startup command line parameters. That way the application can access multiple databases etc, or different tablespaces in the same instance etc etc. It's much more flexible and powerful as well as being much more secure. HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Installation Routines (Joseph Quigley)
> Also, there was a project at some point that aimed at making Linux > applications into self-contained "executable folders" (like .app > bundles in Mac OS X). I don't remember the name, but I recall Rox-filer > supports it. Tcl/Tk now comes in such a bundle, it makes installation a breeze and you can carry it around on a USB memory stick. I love it. Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Re: Error Raising
The tutorial is one of the documents, but you should have downloaded all of the documentation for the current version, not just the tutor. Alan G. - Original Message - From: "Joseph Quigley" <[EMAIL PROTECTED]> To: ; Sent: Thursday, April 21, 2005 3:43 PM Subject: [Tutor] Re: Error Raising > Ahh. I really like the ability to make my own exceptions. This info will > help alot. > Thanks, > Joe > PS. Would the Tutorial included with IDLE be the same as the site's docs? > > > >The standard (built-in) exceptions are documented here: > >http://docs.python.org/lib/module-exceptions.html > > > >If you don't find any that suit you, defining your own is as easy as > > > >class MyException(Exception): > >pass > > > > > >try: > >raise MyException > >except MyException: > >... > > > >Kent > > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] trouble setting the environment
> Is this possible? I vaguely remember something about the system env and the > interpreters env being separate after the interpreter starts up. When you execute another process it gets its own environment. When it dies its environment dies with it. You can get round this in your case by forking the child process and reading the environment variables and writing them back via a pipe to the original program - messy but it works! > >>> os.system(". envSet.ksh") > 0 > >>> os.getenv("OPSBIN") > >>> > > What is the 0. The return value from os.system(). It basically means the command ran without errors. Not too useful normally. popen() is better if you want to read the output (it basically does the fork/pipe thing automagically for you) So if you popen a script that runs your ksh file then prints the environment variables, you can read them into your program... HTH, Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] GNUPLOT
Hello, I just ran into a similar problem. Here's what I found: http://sourceforge.net/tracker/index.php?func=detail&aid=416091&group_id=17434&atid=217434 Just follow the instructions on the link and everything should work fine. I think it has to do with emulating the unix pipe not being available on windows, but I'm not sure. After I did this everything worked fine. Hope this works for you, Chris On 4/21/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hi > > > > I have also now tried this on version 2.4 and w2k.no luck. Anything > > special > > with installing gnuplot or just extracting it and running the .exe.. > > No, nothing special that I remember. This thread on c.l.python has a > suggestion at the end that > might help: > http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/523e2e6af79281af/67f29c3f09058a10?rnum=2&hl=en#67f29c3f09058a10 > > This thread suggests to make sure the executable is in your PATH environment > variable: > http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/bcc75878335bf571/49322acb8520f46f?hl=en#49322acb8520f46f > > Actually they are both suggesting the same thing, that the exe is not being > found. > > Kent > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] GNUPLOT
Hi all I thank you all who have particapted in solving/providing good feedback to this GNUPLOT issue. I have managed to get this to work it was just simply adding the following path to the gp_win32.py file under the site packages: gnuplot_command = r'"C:\Program Files\gp373w32\pgnuplot.exe"' many thanks Ray >-- Original-Nachricht -- >Date: Thu, 21 Apr 2005 14:30:05 -0700 >From: dreamz93 <[EMAIL PROTECTED]> >To: tutor@python.org >Subject: Re: [Tutor] GNUPLOT >Reply-To: dreamz93 <[EMAIL PROTECTED]> > > >Hello, > >I just ran into a similar problem. Here's what I found: > >http://sourceforge.net/tracker/index.php?func=detail&aid=416091&group_id=17434&atid=217434 > >Just follow the instructions on the link and everything should work >fine. I think it has to do with emulating the unix pipe not being >available on windows, but I'm not sure. After I did this everything >worked fine. > >Hope this works for you, >Chris > >On 4/21/05, Kent Johnson <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED] wrote: >> > Hi >> > >> > I have also now tried this on version 2.4 and w2k.no luck. Anything >special >> > with installing gnuplot or just extracting it and running the .exe.. >> >> No, nothing special that I remember. This thread on c.l.python has a >> suggestion >at the end that >> might help: >> http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/523e2e6af79281af/67f29c3f09058a10?rnum=2&hl=en#67f29c3f09058a10 >> >> This thread suggests to make sure the executable is in your PATH environment >variable: >> http://groups-beta.google.com/group/comp.lang.python/browse_frm/thread/bcc75878335bf571/49322acb8520f46f?hl=en#49322acb8520f46f >> >> Actually they are both suggesting the same thing, that the exe is not being >found. >> >> Kent >> >> >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> >___ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: Weird import problem with PythonIDE on Mac (was 'import problem')
### def y1(): pass def foo(): from __main__ import y1 pass foo() ### Here is a version of the code, stripped of the timeit code. The above segment exhibits the same symptoms as the previously submitted one. Even though I am running this as "__main__" it behaves as though it is not __main__. i.e. if I run this with pyOxide without the 'run as __main__' option, it generates the same ImportError ('Can't import y1') as it does when run in the PythonIDE. In the pythonIDE it generates the error whether the 'run as __main__' option is on or off. As a test of that option, I verified that the following code only runs when the __main__ option is on and it worked as expected: ### if __name__=='__main__': print 'running as main' ### /c ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Weird import problem with PythonIDE on Mac (was 'import problem')
From: Kent Johnson Is it possible that the script is not running as __main__? Add print __name__ to the script and see what it says... It says '__main__'. Here is the end of the output after printing vars() if that helps: '__file__': '/Users/csmith/Desktop/misc python/timeit eg.py', 't': , 'y1': , '__name__': '__main__', 'y2': /c ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor