0

I am trying to use python 2.7.8 came with splunk 6 for some XML parsing usign lxml.

from lxml import etree

I see below error

[root@**** bin]# ./python some.py
Traceback (most recent call last):
  File "some.py", line 1, in <module>
    from lxml import etree
ImportError: libexslt.so.0: cannot open shared object file: No such file or directory

Also I have this in splunk/lib/

lrwxrwxrwx  libexslt.so -> libexslt.so.0.8.17
lrwxrwxrwx  libexslt.so.0 -> libexslt.so.0.8.17
-r-xr-xr-x  libexslt.so.0.8.17

Thanks for the help

Sharath
  • 320
  • 1
  • 2
  • 11
  • 1
    See: [Why can't Python find shared objects that are in directories in sys.path?](http://stackoverflow.com/questions/1099981/why-cant-python-find-shared-objects-that-are-in-directories-in-sys-path) – jedwards Mar 17 '15 at 09:42

2 Answers2

2

Assuming you're running an operating system with manageable library paths through ldconfig utility (like GNU/Linux), you can try the following:

# echo "/your/path/to/splunk/lib" >> /etc/ld.so.conf.d/splunk.conf
# ldconfig

The problem here is that the search path for the shared object isn't set, so the application has no way to know where to find it.

If you're running an operating system that doesn't have ldconfig, i suggest you search a bit for the utility that manages the library paths for that particular case (or just update your question with more information).

If you don't have privileges on that system to perform such operations, you can use environment variables to set such search paths, as suggested in the link referred in the comments to your question (by @jedwards).

pah
  • 4,700
  • 6
  • 28
  • 37
2

If you want to run something out of $SPLUNK_HOME/bin you should use the "splunk cmd" command to properly set up the environment first:

./splunk cmd python some.py

This is the preferred method if you'd like to use the Splunk python, and correctly emulates the way a python script would run if it was triggered from inside Splunk (as an alert script, for example).