Developing for Splunk Enterprise

How to configure Eclipse to work with Splunk python?

lquinn
Contributor

I am currently trying to debug an app for splunk and I would like to be able to look at it in eclipse. However I am struggling to configure eclipse to work with splunk. So far I have installed Eclipse, Tortoise HG and Mercurial. I have opened my repository and attempted to specify the interpreter as splunks python. I have been following instructions from this similar question...

http://answers.splunk.com/answers/100884/how-test-python-in-eclipse.html

In their example they have the python executable in the python27 directory which is inside the splunk bin directory. I however have the python.exe file in straight in the bin directory and then the python 27 directory in splunk

ie.

-splunk
    -bin
        -python.exe
    -etc
    -include
    -Python27
    -.....

The error message that occurs when I attempt to add the splunk python interpreter is

  Unable to get info on the interpreter C:\Program Files\Splunk\bin\python.exe

I figured it must be something to do with the fact that the python executable and the directory Python27 are separated. I tried copying the folders from the python27 directory into the bin directory, however it stil could not find all of the relevant files, this time the DLLs. Does anyone have any ideas? Thanks!

0 Karma

paramagurukarth
Builder

Download Splunk Python SDk (zip) from splunk ..
Extract it...
you can see two folders.. splunklib and utils...
Copy those folders into your machine's python\lib\site-packages folder....
Also copy the contents of %SPLUNK_HOM%\Python-2.7\Lib\site-packages to python\lib\site-packages...

In your eclipse, Configure your system's python (Installed by you) as python interpreter

You can debug splunk python sdk...

alacercogitatus
SplunkTrust
SplunkTrust

Ok, try this. In $SPLUNK_HOME, create a file splunk_python.cmd. Put the following in that file (change the path to whatever you have installed it as):

echo off
"C:\Program Files\Splunk\bin\splunk.exe" cmd python %*

Now in Eclipse, create a new python interpreter, and point it at C:\Program Files\Splunk\bin\splunk_python.cmd (change the path to whatever you have installed it as)

I was able to do something similar on Linux, and it works well.

alacercogitatus
SplunkTrust
SplunkTrust

What version of eclipse are you testing?

0 Karma

lquinn
Contributor

Luna Release 4.4.0

0 Karma

lquinn
Contributor

Hi, thanks for your answer. I think you're on the right lines! I have followed your instructions above however when I added the splunk_python.cmd as the python interpreter I encountered the error

Python stdlib not found or stdlib found without .py files.

I tried manually pointing it in the direction of Python2.7/Lib however I ended up getting even more errors!

0 Karma
*NEW* Splunk Love Promo!
Snag a $25 Visa Gift Card for Giving Your Review!

It's another Splunk Love Special! For a limited time, you can review one of our select Splunk products through Gartner Peer Insights and receive a $25 Visa gift card!

Review:





Or Learn More in Our Blog >>