[Pythonmac-SIG] Gtk issues
[A bit of a noob here, running Tiger on a Mac mini] Spent well over an hour last night with MacPorts, installing modules necessary to run gramps. The software needs several modules, particularly Gtk. For the past couple of weeks, I've tried several methods of installing Gtk, including Fink and trying to compile it myself, and while I get few/no errors, gramps each time burps on the line: import gtk and replies: No module named gtk The relevant batch of code ... try: import pygtk pygtk.require('2.0') except ImportError: pass import gtk from gtk import glade import gobject I add the pygtk info because the error exception doesn't appear to check for much, so I'm wondering if that isn't a cause of the gtk problem. If I type: port installed gtk2 I get: gtk2 @2.16.1_4+darwin_8+x11 (active) If I type: port installed py25-gtk I get: py25-gtk @2.14.1_0 (active) My hunch is that this is a sys.path problem. But if so, I don't know what file to look for so that I can add the path to sys.path. There are several files with gtk in the name on my hard drive, _gtk.so? mt ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] where do I store my Python programs
Hi All, I have a mac mini mac os 10.4.11. I also have aquamac for an editor. I have some simple programs stored in text files. and I try to run them using aquamac, but I get the following error message steps taken: launch aquamacs File - new buffer in new window File -new buffer in mode python Python- start interpreter python first.py File stdin, line 1 python first.py ^ SyntaxError: invalid syntax I would like to know if this is a case of files not being seen by the python interpreter or what could be done Regards ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] crankd for monitoring OS X
I ran across this project yesterday, and thought I'd point it out to others: http://code.google.com/p/pymacadmin/ A collection of Python utilities for Mac OS X system administration. In particular, check out crankd, a Python program for monitoring various kinds of OS X events. Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Whats the invalid syntax about
Hello, I have a mac mini mac os 10.4.11 aquamacs 22.3.1. I wrote this program (please see below) after i got a python prompt (this was after starting the interpreter in aquamacs) please suggest what could have gone wrong here why am i getting a syntax error some_list = [3,6,2,5] i=1 while i 3: print some_list[i], ; i=i+1 print some_list[3] File stdin, line 4 print some_list[3] ^ SyntaxError: invalid syntax ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] question about garbage collection with NSApplication.run()
I'm writing a Python program that has a main that looks like this: application = NSApplication.sharedApplication() # set up handler for network change notification SCDynamicStoreSetNotificationKeys(DYNSTORE, None, [NETWORK_KEY,]) # Get a CFRunLoopSource for our store session and add it to the application's runloop: CFRunLoopAddSource( NSRunLoop.currentRunLoop().getCFRunLoop(), SCDynamicStoreCreateRunLoopSource(None, DYNSTORE, 0), kCFRunLoopCommonModes ) # add a timer for application scan events timer = NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_( periodicity, scanner, objc.selector(scanner.scan, signature=v@:), None, True) # using an NSRunLoop avoids Activity Monitor complaining about not responding application.run() Do I need to do anything about NSAutoreleasePools? My understanding is that this is single-threaded, and that NSApplication.run will handle periodic drainage of the default main thread release pool. Bill ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] Whats the invalid syntax about
please suggest what could have gone wrong here why am i getting a syntax error It's a quirk of the interactive interpreter. To terminate a loop you need a blank input line: some_list = [3,6,2,5] i = 1 while i 3: ... print some_list[i], ; ... i = i + 1 ... 6 ; 2 ; print some_list[3] 5 -- Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/ America's vaunted free press notwithstanding, story ideas that expose the unseemly side of actual or potential advertisers tend to fall by the wayside. Not quite sure why. -- Jim Thornton ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] where do I store my Python programs
beegee beegee beege...@gmail.com (bb) wrote: bb Hi All, I have a mac mini mac os 10.4.11. I also have aquamac for an editor. bb I have some simple programs stored in text files. and I try to run bb them using aquamac, but I get the following error message bb steps taken: bb launch aquamacs bb File - new buffer in new window bb File -new buffer in mode python bb Python- start interpreter bb python first.py bb File stdin, line 1 bb python first.py bb^ bb SyntaxError: invalid syntax bb I would like to know if this is a case of files not being seen by the bb python interpreter or what could be done The Python interpreter expects a Python statement or expression, like 2+3 or print Hello world. `python first.py' is not a python command nor an expression but a shell command. So you have to issue this in a shell. You can create a shell in Aquamacs by typing `ESC x shell' (without the quotes). Another possibility, after Python- start interpreter, is Python-Execute Buffer. For small snippets of code this may be easier, but for complete programs the shell method may be better. A shell can also be run outside of Aquamacs with the Terminal application. -- Piet van Oostrum p...@cs.uu.nl URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4] Private email: p...@vanoostrum.org ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
[Pythonmac-SIG] Can't get ASDictionary to work (py2app problems?)
Hi, I'm trying to use appscript on my MacBook Pro running OS X 10.5.7 and the stock Apple Python. It's never had appscript installed before. However, I can't get the binary ASDictionary I downloaded to run: Traceback (most recent call last): File /Developer/Applications/appscript/ASDictionary.app/Contents/Resources/__boot__.py, line 31, in module _run('ASDictionary.py') File /Developer/Applications/appscript/ASDictionary.app/Contents/Resources/__boot__.py, line 28, in _run execfile(path, globals(), globals()) File /Developer/Applications/appscript/ASDictionary.app/Contents/Resources/ASDictionary.py, line 17, in module import osax, appscript, mactypes File build/bdist.macosx-10.3-i386/egg/osax.py, line 38, in module File build/bdist.macosx-10.3-i386/egg/aem/aemsend.py, line 82, in send aem.aemsend.EventError: Command failed: Application could not handle this command. (-1708) 2009-05-31 15:42:43.946 ASDictionary[4551:10b] ASDictionary Error 2009-05-31 15:42:43.948 ASDictionary[4551:10b] ASDictionary Error An unexpected error has occurred during execution of the main script EventError: Command failed: Application could not handle this command. (-1708) So I tried building newer versions of everything, which helped in the past. I did run into a problem with modulegraph and newer versions of setuptools but that was easily fixed. Now I seem to be having issues with py2app. First, if I try to use the bundled PyObjC, py2app doesn't pick it up, so I get an error trying to import 'objc'. Next, I tried installing the current PyObjC, but now I get a truly weird error running the built ASDictionary: Traceback (most recent call last): File /Users/nicholas/src/ASDictionary/src/dist/ASDictionary.app/Contents/Resources/__boot__.py, line 31, in module _run('ASDictionary.py') File /Users/nicholas/src/ASDictionary/src/dist/ASDictionary.app/Contents/Resources/__boot__.py, line 28, in _run execfile(path, globals(), globals()) File /Users/nicholas/src/ASDictionary/src/dist/ASDictionary.app/Contents/Resources/ASDictionary.py, line 11, in module import objc File objc/__init__.pyc, line 22, in module File objc/__init__.pyc, line 19, in _update File objc/_objc.pyc, line 18, in module File objc/_objc.pyc, line 15, in __load ImportError: '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/objc/_objc.so' not found 2009-05-31 15:47:49.610 ASDictionary[4560:10b] ASDictionary Error 2009-05-31 15:47:49.612 ASDictionary[4560:10b] ASDictionary Error An unexpected error has occurred during execution of the main script ImportError: '/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload/objc/_objc.so' not found Why is it trying to look for _objc.so *there*? It's actually in /Library/Python/2.5/site-packages/pyobjc_core-2.2b2-py2.5-macosx-10.5-i386.egg/objc/_objc.so. If I build ASDictionary with py2app -A, I'm back to the old error about not being able to import objc: Traceback (most recent call last): File /Users/nicholas/src/ASDictionary/src/dist/ASDictionary.app/Contents/Resources/__boot__.py, line 58, in module _run(('\x00\x00\x00\x00\x01(\x00\x02\x00\x00\x04Babs\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc1V\xc6\x82H+\x00\x00\x01-\xf1\xbf\x0fASDictionary.py\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01-\xf2\x03\xc6HIk\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00I \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x08\x00\x00\xc1W\x0c\xd2\x00\x00\x00\x11\x00\x08\x00\x00\xc6H\x8f\xbb\x00\x00\x00\x0e\x00 \x00\x0f\x00A\x00S\x00D\x00i\x00c\x00t\x00i\x00o\x00n\x00a\x00r\x00y\x00.\x00p\x00y\x00\x0f\x00\n\x00\x04\x00B\x00a\x00b\x00s\x00\x12\x003Users/nicholas/src/ASDictionary/src/ASDictionary.py\x00\x00\x13\x00\x01/\x00\x00\x15\x00\x02\x00\x0f\xff\xff\x00\x00', '/Users/nicholas/src/ASDictionary/src/ASDictionary.py')) File /Users/nicholas/src/ASDictionary/src/dist/ASDictionary.app/Contents/Resources/__boot__.py, line 54, in _run execfile(path, globals(), globals()) File /Users/nicholas/src/ASDictionary/src/ASDictionary.py, line 11, in module import objc ImportError: No module named objc 2009-05-31 15:49:24.391 ASDictionary[4605:10b] ASDictionary Error 2009-05-31 15:49:24.394 ASDictionary[4605:10b] ASDictionary Error An unexpected error has occurred during execution of the main script ImportError: No module named objc despite the fact that there is not one but *two* copies of PyObjC installed. (Everything works fine if I just 'import objc' from a script, of course.) Help? I just wanted to write a quick script to tag some PDFs and I'm now over two hours into this... it's
Re: [Pythonmac-SIG] where do I store my Python programs
Piet van Oostrum wrote: Another possibility, after Python- start interpreter, is Python-Execute Buffer. For small snippets of code this may be easier, but for complete programs the shell method may be better. do check out ipython -- it' s a nice way to do this. I wonder if ipython can be the python shell for Aquamacs? That would be slick. beegee beegee wrote: please suggest what could have gone wrong here why am i getting a syntax error I think you've got your answer, but I can't help myself. You really want to spell this more like: some_list = [3,6,2,5] for item in some_list: print item, ; print some_list[3] or even better: ;.join([str(i) for i in some_list]) Welcome to the joy of Python! -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/ORR/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig