Python dbm open returns error 22

software development


I have a python script which displays a framed image. Information about the image is stored in a dbm file which is generated by perl. File type is

gallery/ImageDatabase.db: Berkeley DB 1.85 (Hash, version 2, native byte-order)

Attempts to run the script and open the dbm file yeild:

[khartoum]$ python -d cgi/
Traceback (most recent call last):
File “cgi/”, line 136, in
db_file = (image_db_path, ‘r’)
dbm.error: (22, ‘Invalid argument’)

I believe the file path is correct. When it is incorrect I get a different error. This script works when run under Mac OS and python 2.6 but not on dreamhost site which has python 2.5.2.

I’m stumped and would appreciate any help.



DBM can be pretty picky at times. If you have any choice in the matter, I’d try using another database format (preferably MySQL, or SQLite if you’re wedded to the idea of storing it in a file). Both are easy enough to access from both Python and Perl.


Thanks for the reply. I’ll take a look at SQLLite. Single file is preferred for how the database is built and deployed.

Some simple fix to what I have would still be preferred. Do you think the error indicates some incompatible version of the file?