Splunk Dev

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
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...