6

I'm trying to create an LMDB data base file in Python to be used with Caffe according to this tutorial. The commands import numpy as np and import caffe run perfectly fine. However, when I try to run import lmdb and import deepdish as dd, I'm getting the following errors:

    >>> import lmdb
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named lmdb
    >>> import deepdish as dd
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named deepdish

I'm running Python 2.7.9 through Anaconda 2.2.0 (64-bit) on Ubuntu 14.04. While installing the dependencies for Caffe according to this page, I've already installed the lmdb package through sudo apt-get install liblmdb-dev.

Any ideas why this error might be occuring?

Dr. Prasanna Date
  • 745
  • 1
  • 9
  • 29
  • you seem to have path definition issues. please check you PATH variable and verify that it indeed points to the location of the lmdb package – Shai Jun 11 '15 at 15:33
  • When I do `echo $PATH`, it returns the following: `/home/pras/anaconda/bin:$/usr/include:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games`. When I do `dpkg -L liblmdb-dev`, I get these: `/. /usr /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/liblmdb.a /usr/share /usr/share/doc /usr/share/doc/liblmdb-dev /usr/share/doc/liblmdb-dev/copyright /usr/include /usr/include/lmdb.h /usr/lib/x86_64-linux-gnu/liblmdb.so /usr/share/doc/liblmdb-dev/changelog.Debian.gz` Now, which of these should I add to $PATH? – Dr. Prasanna Date Jun 11 '15 at 16:51
  • 1
    Well, I tried to follow instructions as mentioned [here](https://lmdb.readthedocs.org/en/release/#installation-unix). `pip install lmdb` seemed to do the trick! – Dr. Prasanna Date Jun 11 '15 at 17:01
  • You should post this as an answer – Shai Jun 11 '15 at 17:02

3 Answers3

12

Well, the apt-get install liblmdb-dev might work with bash (in the terminal) but apparently it doesn't work with Anaconda Python. I figured Anaconda Python might require it's own module for lmdb and I followed this link. The Python installation for lmdb module can be performed by running the command pip install lmdb in the terminal. And then import lmdb in Python works like a charm!

The above installation commands may require sudo.

ypx
  • 1,459
  • 11
  • 19
Dr. Prasanna Date
  • 745
  • 1
  • 9
  • 29
1

If you're using Anaconda, then this can solve your problem (it worked for me):

conda install -c https://conda.binstar.org/dougal lmdb
Yazeed
  • 19
  • 2
1

For Anaconda users, installing python-lmdb package from conda-forge should fix the lmdb import error:

conda install -c conda-forge python-lmdb

This was tested on conda 4.5.11 on an lxc-containerized system running Ubuntu 18.04.

Note that there is a conda package named lmdb (without python-), installable via:

conda install -c conda-forge lmdb

that does not fix the import error.

Mohamed Laradji
  • 144
  • 3
  • 6