web-dev-qa-db-ja.com

bsddbパッケージのインストール-python

私はpythonにまったく新しいです。bsdddbをインポートしようとすると、このメッセージが表示されます

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bsddb/__init__.py", line 67, in <module>
    import _bsddb
ImportError: No module named _bsddb

thisthis を使用したので、このパッケージをダウンロードしましたbsddb3-4.5.0.tar.gz。私はそれをどうするつもりですか、python install setup.py int bsddb3-4.5.0 in the right directory(私はosxを使用しています)を実行しようとしました。それから私は

Can't find a local BerkeleyDB installation.
(suggestion: try the --berkeley-db=/path/to/bsddb option)

誰か助けてくれる?

21
user1611830

bsddbは 2.6から非推奨 です。理想は bsddb3モジュール を使用することです。

私の提案、そして最も簡単なオプションは、 Homebrew をインストールし、それを使用してシステムにBerkeleyDBを取得することです。

brew install berkeley-db

この後、 pip を使用してbsddb3をインストールします

pip install bsddb3

または source をダウンロードして、通常どおりインストールします。

python setup.py install
16
Francisco Roque

同様の問題がありましたが、AGPLライセンスまたはOracleの商用Berkeleyライセンスを使用できなかったため、どの提案もうまくいきませんでした。

_BERKELEYDB_DIR=$(brew --cellar)/berkeley-db/6.1.26 pip install bsddb3
Collecting bsddb3
Using cached bsddb3-6.1.1.tar.gz
Complete output from command python setup.py Egg_info:
Trying to use the Berkeley DB you specified...
Detected Berkeley DB version 6.1 from db.h

******* COMPILATION ABORTED *******

You are linking a Berkeley DB version licensed under AGPL3 or have a commercial license.

AGPL3 is a strong copyleft license and derivative works must be equivalently licensed.

You have two choices:

  1. If your code is AGPL3 or you have a commercial Berkeley DB license from Oracle, please, define the environment variable 'YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION' to any value, and try to install this python library again.

  2. In any other case, you have to link to a previous version of Berkeley DB. Remove Berlekey DB version 6.x and let this python library try to locate an older version of the Berkeley DB library in your system. Alternatively, you can define the environment variable 'BERKELEYDB_DIR', or 'BERKELEYDB_INCDIR' and 'BERKELEYDB_LIBDIR', with the path of the Berkeley DB you want to use and try to install this python library again.

Sorry for the inconvenience. I am trying to protect you.

More details:

    https://forums.Oracle.com/message/11184885
    http://lists.debian.org/debian-legal/2013/07/

******* COMPILATION ABORTED *******
_

ただし、古いバージョンに戻すと修正されました。

古いバージョンのberkeley-dbをbrewでインストールします

_brew install berkeley-db4_

次に、提案されているように、pipでbsddb3をインストールします

_pip install bsddb3_

その後

BERKELEYDB_DIR=$(brew --cellar)/berkeley-db4/4.8.30 pip install bsddb3

(以前のberkeley-db version ディレクトリを参照するようにStefan Schmidtのコメントから変更)

最後に、説明に従ってパッチをdbhash.pyに適用します ここ

10
bamdan

@bamdanの回答では、古いバージョンのBerkeley DBを使用していますが、最新のBerkeley DBを引き続き使用する場合は、

  • まず、最新のBerkeley DBをインストールします

    pip install berkeley-db
    
  • 次に、環境変数YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSIONを設定して、ライセンスがあることを示します

    BERKELEYDB_DIR=$(brew --cellar)/berkeley-db4/6.1.26 YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=yes pip install bsddb3
    
7
soulmachine