shelve.open() and error 22: invalid argument

Jonathan Gardner jgardner.jonathangardner.net at gmail.com
Thu Nov 1 16:41:13 EDT 2007


On Nov 1, 1:08 pm, max.agin... at gmail.com wrote:
> Hi everyone
>
> I've come across the following problem: on two different linux
> machines, both running python 2.5 (r25:51908), I have the same file
> 'd.dat'. The md5 checksums are the same.
>
> Now, on one machine the following code works
>
> >>> import shelve
> >>> d=shelve.open('d.dat')
>
> while on the other...
>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "local/lib/python2.5/shelve.py", line 225, in open
>     return DbfilenameShelf(filename, flag, protocol, writeback)
>   File "local/lib/python2.5/shelve.py", line 209, in __init__
>     Shelf.__init__(self, anydbm.open(filename, flag), protocol,
> writeback)
>   File "local/lib/python2.5/anydbm.py", line 83, in open
>     return mod.open(file, flag, mode)
>   File "local/lib/python2.5/dbhash.py", line 16, in open
>     return bsddb.hashopen(file, flag, mode)
>   File "local/lib/python2.5/bsddb/__init__.py", line 299, in hashopen
>     e = _openDBEnv(cachesize)
>   File "local/lib/python2.5/bsddb/__init__.py", line 355, in
> _openDBEnv
>     e.set_lk_detect(db.DB_LOCK_DEFAULT)
> bsddb.db.DBInvalidArgError: (22, 'Invalid argument')
>
> What is happening? I am running the same Python interpreter on the
> same file! Why different results? (To make things weirder, this
> actually fails on the machine in which I created the d.dat file using
> the shelve module!)
>

This comes up outside of Python as well. Look into your BDB setup. I
bet you that the two machines have different versions of BDB
libraries.




More information about the Python-list mailing list