Hi, Chris was right --- when I built my Python 2.6 distribution on my iMac, it didn't build bsddb nor gdbm. There is a file Modules/Setup in which you can enable Python to be built with these modules. The problem, however, is that these modules depend on other libraries on your system, and I have great difficulties building these libraries from scratch.
Has any of you tried using MacPorts for building and maintaining your open source packages? Does it work well? I am hesitant to use fink because I keep reading that fink breaks a lot of things. Thanks, Jenny On Sun, May 3, 2009 at 12:54 PM, Christopher Lee <l...@chem.ucla.edu> wrote: > Hi Jenny, > this is a shelve problem, not a pygr.Data problem or a MySQLdb problem. > The error message indicates that the shelve's iterator method failed, which > caused Pygr to try a fall-back iterator method for gdbm (which handles the > case where your Python install lacks a working bsddb module). But your > shelve's dict is clearly not a gdbm index either (thus the attribute error). > There are a couple possibilities here: > > - the question is why your shelve's iterator method fails. Please test > creating a shelve, inserting a bunch of items, closing, re-opening, and > trying iterating over the items (using iter(), e.g. for k in > iter(myshelve):). > > - perhaps your Python 2.6 lacks a working bsddb? Sometimes it fails to > compile right on Mac... try the following: > import _bsddb > > - perhaps in the location that it is trying to open you have an old shelve > file from an earlier version of python, which shelve is trying to open, and > failing due to a version mismatch? Look for a file .pygr_data in that > directory and delete it. > > -- Chris > > > > > On May 2, 2009, at 11:54 PM, Jenny Qing Qian wrote: > > Hi Chris, >> >> I finally had MySQLdb installed on my new Mac. But, I ran into the >> following pygr.Data problem: >> >> Python 2.6.2 (r262:71600, Apr 29 2009, 23:07:46) >> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import pygr.Data >> >>> pygr.Data.dir('Bio') >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "pygr/metabase.py", line 954, in dir >> download=download)) >> File "pygr/metabase.py", line 821, in dir >> download=download) >> File "pygr/metabase.py", line 538, in dir >> for name in self.db: >> File "pygr/dbfile.py", line 81, in iter_gdbm >> k = db.firstkey() >> AttributeError: firstkey >> >> I thought it might have something to do with the MySQLdb, so I did the >> following test: >> >> [bigmac:~/pygr/pygr] qing% python -i >> Python 2.6.2 (r262:71600, Apr 29 2009, 23:07:46) >> [GCC 4.0.1 (Apple Inc. build 5490)] on darwin >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import MySQLdb >> /Library/Frameworks/Python64.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-macosx-10.5-universal.egg/MySQLdb/__init__.py:34: >> DeprecationWarning: the sets module is deprecated >> from sets import ImmutableSet >> >>> mydb = MySQLdb.Connect(db='test') >> cursor = mydb.cursor() >> >>> >>> stmt = "DROP TABLE IF EXISTS COLORS" >> cursor.execute(stmt)>>> >> __main__:1: Warning: Unknown table 'colors' >> 0L >> >>> stmt = """CREATE TABLE COLORS ( >> COLOR varchar(32) DEFAULT '' NOT NULL, >> NCOLOR INT UNSIGNED NOT NULL AUTO_INCREMENT, >> PRIMARY KEY (NCOLOR) >> )"""... ... ... ... >> >>> cursor.execute(stmt) >> 0L >> >>> colors = ( ('red',), ('blue',), ('yellow',), ) >> stmt = "INSERT INTO COLORS (COLOR) VALUES (%s)" >> cursor.executemany(stmt, colors) >> >>> >>> 3L >> >>> >> >>> stmt = "select NCOLOR, COLOR from COLORS" >> cursor.execute(stmt) >> resultSet = cursor.fetchall() >> >>> 3L >> >>> >>> for i, color in resultSet: >> print "Color number",i,"is", color >> >> mydb.close()... ... Color number 1 is red >> Color number 2 is blue >> Color number 3 is yellow >> >> So, the MySQLdb module works fine. >> >> Have you seen this AttributeError:firstkey before? >> >> Thanks, >> Jenny >> > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pygr-dev" group. To post to this group, send email to pygr-dev@googlegroups.com To unsubscribe from this group, send email to pygr-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/pygr-dev?hl=en -~----------~----~----~----~------~----~------~--~---