Search code examples
pythonpython-2.7ubuntu-12.04snappy

Can not import snappy in python


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


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/