[英]“ImportError: No module named _bsddb” when opening shelve in Docker container
I want to open a shelve inside a Docker container based in Python's official image, python:2.7.9-wheezy . 我想在基于Python的官方图像python:2.7.9-wheezy的Docker容器中打开一个搁架 。 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
. 在我的主机上问题不存在, _bsddb
位于/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. 这个文件也可以在我的Docker容器中使用,所以我不明白为什么它无法导入。
Ignacio Vazquez-Abrams suggest to install db4-devel
, but this package isn't available in my container. Ignacio Vazquez-Abrams建议安装db4-devel
,但我的容器中没有此软件包。
How do I open the shelve in the Docker container? 如何打开Docker容器中的搁架?
It seems like you need the libdb4.8-dev
package ( link ), but unfortunately this is no longer available since Lucid. 看起来你需要libdb4.8-dev
软件包( 链接 ),但不幸的是,自Lucid以来这已经不再可用了。
I have found some possible solutions: 我找到了一些可能的解决方案:
sudo apt-get install libdb5.1++-dev
( link ) sudo apt-get install libdb5.1++-dev
( link ) libdb4.8++
from the Lucid repository ( link ) 从Lucid存储库安装libdb4.8++
( 链接 ) sudo apt-get install libdb++-dev libminiupnpc-dev
( link , might require reinstalling Python though) sudo apt-get install libdb++-dev libminiupnpc-dev
( 链接 ,可能需要重新安装Python) 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. 编辑: 此页面还提供了有关受支持版本的大量信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.