9

I'm running Windows 7 x64, with Python 3.4. When I run pip install bsddb3 I get:

λ pip install bsddb3
Collecting bsddb3
  Using cached bsddb3-6.1.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "C:\Users\User\AppData\Local\Temp\pip-build-soqf0_qb\bsddb3\setup.py", line 42, in <module>
        import setup3
      File "C:\Users\User\AppData\Local\Temp\pip-build-soqf0_qb\bsddb3\setup3.py", line 375, in <module>
        with open(os.path.join(incdir, 'db.h'), 'r') as f :
    FileNotFoundError: [Errno 2] No such file or directory: 'db/include\\db.h'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\User\AppData\Local\Temp\pip-build-soqf0_qb\bsddb3

So I tried downloading the sources for bsddb3. I made sure I had the BSD DB Windows binaries from Oracle installed; I downloaded them from Berkeley DB 6.1.26.msi. Moving the include and lib directories from the DB install to a /db directory in the bsddb3 folder fixed the problem of not being able to find the libraries. But then the setup failed on a missing variable that's in the posix section but not properly declared in the Windows section.

Fixing that, and a couple of other adjustments, and python setup.py build actually ran the build, but after a bunch of warnings about unsafe conversions it failed with an error:

warning: I don't know what to do with 'runtime_library_dirs': ['db/lib']
error: don't know how to set runtime library search path for MSVC++

I'm not sure what to do next. Other than rewrite the library I was originally trying to use so that it uses SQLAlchemy instead or something.

Isaac
  • 137
  • 1
  • 1
  • 5

2 Answers2

13

One don't really want to spend couple of nights compiling that on Windows, so the best option is to use pre-built binary from Unofficial Windows Binaries for Python Extension Packages.

Download the package for your Python version (cpXX part of the name) and architecture (win_amd64 or win32), like bsddb3-6.1.1-cp34-none-win_amd64.whl, and install it with pip:

pip install bsddb3-6.1.1-cp34-none-win_amd64.whl
cyberj0g
  • 3,707
  • 1
  • 19
  • 34
  • I tried this but it just gives me an error about a wheel file? "bsddb3-6.2.5-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform." - I'm using Windows 7, python 2.7.13. – Adamantus Dec 22 '17 at 20:19
  • 1
    @Adamantus you probably have 32-bit system, pick appropriate package – cyberj0g Dec 25 '17 at 12:11
  • Thank you @cyberj0g bsddb3-6.2.6-cp36-cp36m-win_amd64.whl worked for my Python 3.6 and 64 bit Windows. – ady Aug 13 '18 at 12:14
2

Based on cyberj0g's answer. https://www.lfd.uci.edu/~gohlke/pythonlibs/#bsddb3

pip install bsddb3-6.1.1-cp34-none-win_amd64.whl

Note: the cp part is corresponding to the CPython version.

which means cp36 is for CPython 3.6.And divided into 32-bit and 64-bit versions for windows

  • bsddb3‑6.2.5‑cp36‑cp36m‑win32.whl
  • bsddb3‑6.2.5‑cp36‑cp36m‑win_amd64.whl
K.Andy Wang
  • 401
  • 1
  • 3
  • 14