2

I'm trying to lookup for a "key" in "my.db". I did the following:

import shelve
db_file = os.path.join(self.path_data, 'my_directory', 'my.db')
s = shelve.open(db_file)
val = s["key"]

and I get this error:

 /opt/Python-2.4.3/lib/python2.4/shelve.py in open(filename='/path_here/dir/netmhcpan.db', flag='c', protocol=None, writeback=False, binary=None)
 /opt/Python-2.4.3/lib/python2.4/shelve.py in __init__(self=<DbfilenameShelf instance>, filename='/path_here/dir/netmhcpan.db', flag='c', protocol=None, writeback=False, binary=None)
 /opt/Python-2.4.3/lib/python2.4/anydbm.py in open(file='/path_here/dir/netmhcpan.db', flag='c', mode=438)
......
ImportError: No module named _bsddb
  args = ('No module named _bsddb',) 

Appreciate any help to solve this problem. Thanks.

DGT
  • 2,604
  • 13
  • 41
  • 60

1 Answers1

2

Install db4-devel or the like, then rebuild Python.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
  • It works fine when I do it in python command line, but fails inside a class. – DGT Apr 28 '11 at 00:23
  • @DGT: "but fails inside a class." A completely different question. Accept this answer. Open a new question. – S.Lott Apr 28 '11 at 00:41