shelve.open call gives error

jim-on-linux inq1ltd at inqvista.com
Fri Feb 8 12:19:56 EST 2008


On Friday 08 February 2008 12:10, 
jim-on-linux wrote:
> On Friday 08 February 2008 03:36, waltbrad
>
> wrote:
> > Working through the Mark Lutz book
> > Programming Python 3rd Edition.
> >
> > A couple of modules in the "Preview"
> > chapter give me errors. Both on a
> > shelve.open call:
> >
> > Pretty simple code, (2nd example):
>
 from;
 jim-on-linux
 http://inq1ltd@inqvixta.com
>
 My guess,
 add this and see if it helps

also try import anydbm if not on linux,
 or import dbhash will work on linux

> > =====code begin=====
>
> import dbhash
>
> > import shelve
> > from people import Person, Manager
> >
> > bob = Person('Bob Smith', 42, 30000,
> > 'sweng') sue = Person('Sue Jones', 45,
> > 40000, 'music') tom = Manager('Tom Doe',
> > 50, 50000)
> >
> > db = shelve.open('class-shelve')
> > db['bob'] = bob
> > db['sue'] = sue
> > db['tom'] = tom
> > db.close()
> > ====code end====
> >
> > Error message++++++++
> > Traceback (most recent call last):
> >   File "make_db_classes.py", line 9, in
> > <module> db =
> > shelve.open('class-shelve') File
> > "C:\PYTHON25\lib\shelve.py", line 225,
> > in open return
> > DbfilenameShelf(filename, flag,
> > protocol, writeback) File
> > "C:\PYTHON25\lib\shelve.py", line 209,
> > in __init__ Shelf.__init__(self,
> > anydbm.open(filename, flag), protocol,
> > writeback)
> >   File "C:\PYTHON25\lib\anydbm.py", line
> > 83, in open return mod.open(file, flag,
> > mode) File "C:\PYTHON25\lib\dbhash.py",
> > line 16, in open return
> > bsddb.hashopen(file, flag, mode) File
> > "C:\PYTHON25\lib\bsddb\__init__.py",
> > line 306, in hashopen d.open(file,
> > db.DB_HASH, flags, mode)
> > bsddb.db.DBError: (5, 'Input/output
> > error') ++++++++++End Error message
> >
> > I've looked on the errata pages of his
> > website and used Google to find someone
> > else who ran into this problem. Found
> > someone else who had a similar error but
> > no explanation was given. No other
> > reader of the book seems to have had the
> > problem.
> >
> > I'm using 2.5.1
> >
> > I thought maybe the file had to exist
> > before it could be opened, so I created
> > one with that name, but no dice. A
> > different but similar set of errors.  I
> > also thought maybe there had to be a
> > second argument like 'a', 'r' or 'w'.
> > That doesn't work either.
> >
> > This is the first chapter of the book.
> > It's an overview of the language
> > features. So, this is pretty perplexing.
> >  Any help would be appreciated. Thanks.



More information about the Python-list mailing list