pythonpython-3.6xapian

How to install xapian with Python 3.6 on Ubuntu 16.04?


I installed Python 3.6 on Ubuntu 16.04 on Docker using the ppa:jonathonf/python-3.6 repository. Now I'd like to install xapian so I can use it with Python. I have not found any ready-made packages, so I am trying to build it from sources. I set PYTHON3 and PYTHON3_LIB parameters to point to Python 3.6. During the build process I get the following error:

ImportError: libxapian.so.30: cannot open shared object file: No such file or directory

I tried xapian versions 1.3.7 and 1.4.5 without luck.

How can I install xapian?

Here's a Dockerfile to reproduce my error:

FROM ubuntu:16.04
RUN apt-get update \
  && apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update \
  && apt-get install -y python3-pip docker.io python3.6 python3.6-dev software-properties-common \
      python-software-properties build-essential wget unzip cmake python3-sphinx \
  && cd /usr/local/bin \
  && ln -s /usr/bin/python3.6 python
RUN python -m pip install --upgrade pip

# install xapian 1.4.5
RUN apt-get update && apt-get install -y curl uuid-dev zlib1g-dev
WORKDIR /root
RUN curl --silent --show-error --fail --next -O https://oligarchy.co.uk/xapian/1.4.5/xapian-core-1.4.5.tar.xz
RUN curl --silent --show-error --fail --next -O https://oligarchy.co.uk/xapian/1.4.5/xapian-bindings-1.4.5.tar.xz
RUN tar xvf xapian-core-1.4.5.tar.xz
RUN tar xvf xapian-bindings-1.4.5.tar.xz
WORKDIR /root/xapian-core-1.4.5
RUN ./configure && make && make install
WORKDIR /root/xapian-bindings-1.4.5
RUN ./configure PYTHON3=/usr/bin/python3.6 PYTHON3_LIB=/usr/lib/python3.6 --with-python3 && make && make install
RUN python -c "import xapian"

Solution

  • The problem is that the Xapian library (libxapian.so.30) is being installed into /usr/local/lib by default, but Ubuntu doesn't know that it's been put there yet. You can tell it by adding:

    RUN ldconfig

    after installing the core (so before you change WORKDIR to build the bindings).

    There's some helpful information about ldconfig and library search paths on Ubuntu in the answers to this Unix Stackexchange question.