Question

I use the package named python-snappy. This package requires snappy library. So, I download and install snappy successfully by the following commands such as:

./configure
make
sudo make install

When I import snappy, I receive the errors:

from _snappy import CompressError, CompressedLengthError, \
ImportError: libsnappy.so.1 cannot open shared object file: No such file or directory

I'm using Python 2.7, snappy, python-snappy and Ubuntu 12.04 How can I fix this problem? Thanks

Was it helpful?

Solution

Traditionally you might have to run the ldconfig utility to update your /etc/ld.so.cache (or equivalent as appropriate to your OS). Sometimes it might be necessary to add new entries (paths) to your /etc/ld.so.conf.

Basically the shared object (so) loaders on many versions of Unix (and probably other Unix-like operating systems) use a cache to help resolve their base filenames into actual files to be loaded (usually mmap()'d). This is roughly similar to the intermittent need to run hash -r or rehash in your shell after adding things to directories in your PATH.

Usually you can just run ldconfig with no arguments (possibly after adding your new library's path to your /etc/ld.so.conf text file). Good Makefiles will do this for you during make install.

Here's a little bit more info: http://linux.101hacks.com/unix/ldconfig/

OTHER TIPS

You can install the python-snappy and libsnappy1 from the ubuntu repos:

$ sudo apt-get install libsnappy1 python-snappy 

You should not have to download anything.

Here for e.g. anaconda python

  1. Download snappy from github
  2. also download the python file
  3. extract both files
  4. google-snappy folder

    $ ./configure

    $ make

    $ sudo make install

  5. Then in python folder:

    $ python setup.py build # here I get the same import _snappy error

    $ python setup.py install # after this import works

the following worked for me:

$ conda install python-snappy

then in my code I used:

import snappy
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top