<?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: My own Python script cannot import Splunk Python library modules? in Installation</title>
    <link>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156216#M9833</link>
    <description>&lt;P&gt;Hello, I was the same problem with Mysql module that I was install on my Centos server&lt;/P&gt;

&lt;P&gt;Splunk didn't work with this library, because splunk has they own python library...then you can fix it only added on the begin your script all libraries of python and also you must to add the python Centos library too... as this way&lt;/P&gt;

&lt;H3&gt;Find python packages&lt;/H3&gt;

&lt;P&gt;[root@xxxx]#find / -name site-packages&lt;BR /&gt;
/usr/lib/python2.7/site-packages&lt;BR /&gt;
/usr/lib64/python2.7/site-packages&lt;BR /&gt;
/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages&lt;BR /&gt;
/opt/splunk/lib/python2.7/site-packages&lt;/P&gt;

&lt;H3&gt;Find python binary&lt;/H3&gt;

&lt;P&gt;[root@xxxx]# whereis python&lt;BR /&gt;
python: /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /opt/splunk/bin/python /opt/splunk/bin/python2.7 /usr/share/man/man1/python.1.gz&lt;/P&gt;

&lt;P&gt;include all at begin your script&lt;/P&gt;

&lt;P&gt;import sys&lt;BR /&gt;
sys.path.append('/usr/bin/python2.7')&lt;BR /&gt;
sys.path.append('/usr/lib/python2.7/site-packages')&lt;BR /&gt;
sys.path.append('/usr/lib64/python2.7/site-packages')&lt;/P&gt;

&lt;P&gt;And that's it , you can run mysql module without any problem and create your alerts with this module.&lt;/P&gt;

&lt;H3&gt;Mysql Connection&lt;/H3&gt;

&lt;P&gt;import mysql.connector&lt;/P&gt;

&lt;P&gt;I hope that this fix will help you&lt;BR /&gt;
Joel Urtubia Ugarte&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 16:36:41 GMT</pubDate>
    <dc:creator>joelurtubia</dc:creator>
    <dc:date>2020-09-29T16:36:41Z</dc:date>
    <item>
      <title>My own Python script cannot import Splunk Python library modules?</title>
      <link>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156213#M9830</link>
      <description>&lt;P&gt;My own Python script cannot import Splunk Python library modules?&lt;/P&gt;

&lt;P&gt;[root@localhost bin]# ./qqip.py 8.8.8.8&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "./qqip.py", line 162, in &lt;MODULE&gt;&lt;BR /&gt;
    import splunk.Intersplunk as si&lt;BR /&gt;
ImportError: No module named splunk.Intersplunk&lt;/MODULE&gt;&lt;/P&gt;

&lt;P&gt;[root@localhost bin]# vim qqip.py&lt;/P&gt;

&lt;P&gt;161 import re&lt;BR /&gt;
162 import splunk.Intersplunk as si&lt;BR /&gt;
163 ipre = re.compile("\d+.\d+.\d+.\d+")&lt;BR /&gt;
164 results = []&lt;BR /&gt;
165 if &lt;STRONG&gt;name&lt;/STRONG&gt; == '&lt;STRONG&gt;main&lt;/STRONG&gt;':&lt;/P&gt;

&lt;P&gt;[root@localhost bin]# find / -name &lt;EM&gt;Intersplunk&lt;/EM&gt;&lt;BR /&gt;
/opt/splunk/lib/python2.7/site-packages/splunk/Intersplunk.pyo&lt;BR /&gt;
/opt/splunk/lib/python2.7/site-packages/splunk/Intersplunk.pyc&lt;BR /&gt;
/opt/splunk/lib/python2.7/site-packages/splunk/Intersplunk.py&lt;/P&gt;

&lt;P&gt;？？？&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 06:12:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156213#M9830</guid>
      <dc:creator>laiyongmao</dc:creator>
      <dc:date>2013-11-26T06:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: My own Python script cannot import Splunk Python library modules?</title>
      <link>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156214#M9831</link>
      <description>&lt;P&gt;Splunk comes bundled with its own Python environment. You could either set your PYTHONPATH in order to make use of the packages available in it, or better yet you should run Splunk's python completely: &lt;CODE&gt;/opt/splunk/bin/splunk cmd python &amp;lt;yourfile.py&amp;gt;&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Nov 2013 07:22:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156214#M9831</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-11-26T07:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: My own Python script cannot import Splunk Python library modules?</title>
      <link>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156215#M9832</link>
      <description>&lt;P&gt;Ayn ，Thank you very much！&lt;/P&gt;</description>
      <pubDate>Wed, 27 Nov 2013 02:51:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156215#M9832</guid>
      <dc:creator>laiyongmao</dc:creator>
      <dc:date>2013-11-27T02:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: My own Python script cannot import Splunk Python library modules?</title>
      <link>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156216#M9833</link>
      <description>&lt;P&gt;Hello, I was the same problem with Mysql module that I was install on my Centos server&lt;/P&gt;

&lt;P&gt;Splunk didn't work with this library, because splunk has they own python library...then you can fix it only added on the begin your script all libraries of python and also you must to add the python Centos library too... as this way&lt;/P&gt;

&lt;H3&gt;Find python packages&lt;/H3&gt;

&lt;P&gt;[root@xxxx]#find / -name site-packages&lt;BR /&gt;
/usr/lib/python2.7/site-packages&lt;BR /&gt;
/usr/lib64/python2.7/site-packages&lt;BR /&gt;
/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages&lt;BR /&gt;
/opt/splunk/lib/python2.7/site-packages&lt;/P&gt;

&lt;H3&gt;Find python binary&lt;/H3&gt;

&lt;P&gt;[root@xxxx]# whereis python&lt;BR /&gt;
python: /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.7 /usr/lib64/python2.7 /etc/python /usr/include/python2.7 /opt/splunk/bin/python /opt/splunk/bin/python2.7 /usr/share/man/man1/python.1.gz&lt;/P&gt;

&lt;P&gt;include all at begin your script&lt;/P&gt;

&lt;P&gt;import sys&lt;BR /&gt;
sys.path.append('/usr/bin/python2.7')&lt;BR /&gt;
sys.path.append('/usr/lib/python2.7/site-packages')&lt;BR /&gt;
sys.path.append('/usr/lib64/python2.7/site-packages')&lt;/P&gt;

&lt;P&gt;And that's it , you can run mysql module without any problem and create your alerts with this module.&lt;/P&gt;

&lt;H3&gt;Mysql Connection&lt;/H3&gt;

&lt;P&gt;import mysql.connector&lt;/P&gt;

&lt;P&gt;I hope that this fix will help you&lt;BR /&gt;
Joel Urtubia Ugarte&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:36:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/156216#M9833</guid>
      <dc:creator>joelurtubia</dc:creator>
      <dc:date>2020-09-29T16:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: My own Python script cannot import Splunk Python library modules?</title>
      <link>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/700717#M14191</link>
      <description>&lt;P&gt;is ended up solving a major problem for me using Ansible to setup Splunk and running python scripts inside the Ansible playbook. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2024 21:00:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Installation/My-own-Python-script-cannot-import-Splunk-Python-library-modules/m-p/700717#M14191</guid>
      <dc:creator>ccWildcard</dc:creator>
      <dc:date>2024-10-01T21:00:28Z</dc:date>
    </item>
  </channel>
</rss>

