2013-04-14 21 views
16

Sono totalmente nuovo per Python e ho questo messaggio quando si tenta di importare bsdddbInstallazione bsddb pacchetto - python

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 

così ho seguito this e this, così ho scaricato questo pacchetto bsddb3-4.5.0.tar.gz. Cosa dovrei fare con esso, ho provato a eseguire python install setup.py int il bsddb3-4.5.0 nella directory giusta (sto usando un osx). Poi ottengo

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

Qualcuno potrebbe aiutare?

risposta

15

bsddb è deprecated since 2.6. L'ideale è utilizzare the bsddb3 module.

Il mio suggerimento, e di gran lunga l'opzione più semplice, è quello di installare Homebrew e usarlo per ottenere BerkeleyDB sul sistema:

brew install berkeley-db 

Dopo questo bsddb3 installazione utilizzando pip

pip install bsddb3 

o da scaricare il source e installare normalmente.

python setup.py install 
+7

installazione pip diritto non ha funzionato per me, ho dovuto andare alla directory di origine di bsddb3 e fare un installazione python.py installazione --berkeley-db = $ (brew --prefix)/berkeley-db /5.3.21/ –

+0

Sembra che potrebbe essere spostato di nuovo in Brew, espandendo il commento di Chmouel: 'python setup.py installa --berkeley-db = \' trova $ (brew --prefix)/*/berkeley-db/5 * -name berk * ​​\ '' – Sean

+8

Questo ha funzionato per me su Mavericks usando 'python' da Apple e' pip' e 'berkeley-db' da Homebrew (come root):' BERKELEYDB_DIR = $ (brew --cellar) /berkeley-db/5.3.28 pip installa bsddb'' (per i dettagli vedi http://chriszf.posthaven.com/getting-berkeleydb-working-with-python-on-osx) –

8

ho avuto un problema simile, ma nessuno dei suggerimenti ha lavorato per me come non ho potuto usare la licenza AGPL o una licenza Berkeley commerciale da Oracle.

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 ******* 

Tuttavia, il ripristino di una versione precedente lo ha risolto.

installare la versione precedente di Berkeley-db con birra

brew install berkeley-db4

Poi, come suggerito installare bsddb3 con pip

pip install bsddb3

Poi

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

(modificato da un commento di Stefan Schmidt riferimento alla directory vecchio Berkeley-db version)

Infine applicare la patch al dbhash.py come descritto here.

6

@bamdan 's risposta utilizza una vecchia versione di Berkeley DB, se si vuole ancora utilizzare l'ultima, Berkeley DB,

  • In primo luogo, installare l'ultima Berkeley DB

    pip install berkeley-db 
    
  • In secondo luogo, impostare una variabile d'ambiente YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION per indicare che si ha la licenza

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

Versione agnostica versione:' BERKELEYDB_DIR = $ (brew --prefix berkeley-db) YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION = si pip installa bsddb3' –

Problemi correlati