5

I want to open a shelve inside a Docker container based in Python's official image, python:2.7.9-wheezy. But I get an import error.

syncer/util.py:19: in get_from_shelve
    db = shelve.open(conf.SHELVE_LOCATION)
/usr/local/lib/python2.7/shelve.py:239: in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
/usr/local/lib/python2.7/shelve.py:223: in __init__
    Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
/usr/local/lib/python2.7/anydbm.py:84: in open
    mod = __import__(result)
/usr/local/lib/python2.7/dbhash.py:7: in <module>
    import bsddb
...
E           ImportError: No module named _bsddb

On my host machine the problem isn't there and _bsddb is located at /usr/lib/python2.7/lib-dynload/_bsddb.so. This file is also available in my Docker container, so I don't understand why it can't be imported.

Ignacio Vazquez-Abrams suggest to install db4-devel, but this package isn't available in my container.

How do I open the shelve in the Docker container?

Community
  • 1
  • 1
OrangeTux
  • 11,142
  • 7
  • 48
  • 73

1 Answers1

1

It seems like you need the libdb4.8-dev package (link), but unfortunately this is no longer available since Lucid.

I have found some possible solutions:

  1. sudo apt-get install libdb5.1++-dev (link)
  2. Installing libdb4.8++ from the Lucid repository (link)
  3. sudo apt-get install libdb++-dev libminiupnpc-dev (link, might require reinstalling Python though)

Hope it helps!

(I'm on the train right now, so will definitely test them for you later)


EDIT: Also this page gives a lot of information about supported versions.

Community
  • 1
  • 1
mauvm
  • 3,586
  • 3
  • 18
  • 19
  • Unfortunately, it didn't work for me. For now I use [google/python](https://registry.hub.docker.com/u/google/python/). But this image doesn't contains Python 2.7.9, instead it's shipped with Python 2.7.2 – OrangeTux Feb 01 '15 at 19:26