<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python script. Module not loading when executed by splunk in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76350#M1062</link>
    <description>&lt;P&gt;Splunk uses it's own python to execute scripts. So if Splunk Python doesn't know about _mssql, it won't find it. Did you install _mssql to the file system? Try running manually with &lt;CODE&gt;splunk cmd python /path/to/your/script&lt;/CODE&gt;. I got around that by using a sh script to call the python script with &lt;CODE&gt;#!/usr/bin/python&lt;/CODE&gt; as the executable to use. &lt;/P&gt;</description>
    <pubDate>Mon, 01 Oct 2012 15:33:46 GMT</pubDate>
    <dc:creator>alacercogitatus</dc:creator>
    <dc:date>2012-10-01T15:33:46Z</dc:date>
    <item>
      <title>Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76349#M1061</link>
      <description>&lt;P&gt;I have a python script on our splunk server to ingest data from a database using pymssql and _mssql. I added this script through the web gui in Manager &amp;gt; Data Inputs &amp;gt; Scripts. I  can run the script manually just fine. But when its executed by splunk, in the splunkd logs it says ImportError: No module named _mssql.&lt;/P&gt;

&lt;P&gt;The pymssql/_mssql package was installed manually.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2012 15:03:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76349#M1061</guid>
      <dc:creator>ryan461</dc:creator>
      <dc:date>2012-10-01T15:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76350#M1062</link>
      <description>&lt;P&gt;Splunk uses it's own python to execute scripts. So if Splunk Python doesn't know about _mssql, it won't find it. Did you install _mssql to the file system? Try running manually with &lt;CODE&gt;splunk cmd python /path/to/your/script&lt;/CODE&gt;. I got around that by using a sh script to call the python script with &lt;CODE&gt;#!/usr/bin/python&lt;/CODE&gt; as the executable to use. &lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2012 15:33:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76350#M1062</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2012-10-01T15:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76351#M1063</link>
      <description>&lt;P&gt;That does get it to execute, the data being ingested was being printed, which splunk would read. But now that its a shell script executing it, i imagine ill have to write to a file or something?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2012 15:48:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76351#M1063</guid>
      <dc:creator>ryan461</dc:creator>
      <dc:date>2012-10-01T15:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76352#M1064</link>
      <description>&lt;P&gt;You could, but I just use the python print command, and splunk eats it just fine. I used the exec command from the sh script and it works great.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2012 15:51:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76352#M1064</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2012-10-01T15:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76353#M1065</link>
      <description>&lt;P&gt;I just use wrapper python script with non-splunk python with installed modules in scripted input. (taken from &lt;A href="http://splunk-base.splunk.com/answers/10839/scripted-lookup-script-doesnt-work-with-splunk-python-version-but-works-fine-with-python-27"&gt;here&lt;/A&gt;) Something like that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import os, sys
for envvar in ("PYTHONPATH", "LD_LIBRARY_PATH"):
    if envvar in os.environ:
        del os.environ[envvar]
python_executable = "D:\Python27\python.exe"
real_script = "path_to_script"
os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:])
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Oct 2012 06:20:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76353#M1065</guid>
      <dc:creator>dalglish</dc:creator>
      <dc:date>2012-10-02T06:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76354#M1066</link>
      <description>&lt;P&gt;Guys,&lt;/P&gt;

&lt;P&gt;Instead setting all those parameters and creating subproccess.&lt;BR /&gt;
Simply copy your required packages/files from &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;&lt;STRONG&gt;/usr/local/lib/python2.7/dist-packages&lt;/STRONG&gt; &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;STRONG&gt;/opt/splunk/lib/python2.7/site-packages/&lt;/STRONG&gt;&lt;/P&gt;

&lt;HR /&gt;</description>
      <pubDate>Fri, 27 Sep 2013 14:18:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76354#M1066</guid>
      <dc:creator>asifhj</dc:creator>
      <dc:date>2013-09-27T14:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76355#M1067</link>
      <description>&lt;P&gt;Possible, but if you upgrade, you may lose the files.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2013 14:26:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76355#M1067</guid>
      <dc:creator>alacercogitatus</dc:creator>
      <dc:date>2013-09-27T14:26:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python script. Module not loading when executed by splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76356#M1068</link>
      <description>&lt;P&gt;I downvoted this post because this is not supported, and as a comment suggested, will break between upgrades (and also not be transferrable between systems)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2016 17:37:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-script-Module-not-loading-when-executed-by-splunk/m-p/76356#M1068</guid>
      <dc:creator>David</dc:creator>
      <dc:date>2016-11-29T17:37:06Z</dc:date>
    </item>
  </channel>
</rss>

