<?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: Force python3 on custom commands in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483032#M193281</link>
    <description>&lt;P&gt;&lt;A href="https://www.splunk.com/blog/2019/07/01/admins-and-developers-we-re-transitioning-to-python-3.html"&gt;https://www.splunk.com/blog/2019/07/01/admins-and-developers-we-re-transitioning-to-python-3.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Sep 2019 18:55:14 GMT</pubDate>
    <dc:creator>starcher</dc:creator>
    <dc:date>2019-09-17T18:55:14Z</dc:date>
    <item>
      <title>Force python3 on custom commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483030#M193279</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;
I´ve a custom command but it requieres python3 for launch properly.&lt;/P&gt;

&lt;P&gt;Errors on job inspector:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;09-17-2019 13:49:30.497 INFO  ChunkedExternProcessor - Running process: /opt/splunk/bin/python /opt/splunk/etc/apps/arcsightapi/bin/bypass.py
09-17-2019 13:49:30.666 ERROR ChunkedExternProcessor - stderr: Error in sitecustomize; set PYTHONVERBOSE for traceback:
09-17-2019 13:49:30.666 ERROR ChunkedExternProcessor - stderr: AttributeError: module 'sys' has no attribute 'setdefaultencoding'
09-17-2019 13:49:30.666 ERROR ChunkedExternProcessor - Failed attempting to parse transport header: module 'requests.packages.urllib3' has no attribute 'disable_warnings'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if i exec under terminal with python3 support works nice:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;root@horsell:/opt/splunk/bin# ./splunk cmd python3 ../etc/apps/arcsightapi/bin/client.py  -h
Error in sitecustomize; set PYTHONVERBOSE for traceback:
AttributeError: module 'sys' has no attribute 'setdefaultencoding'
usage: client.py [-h] [-a AREA] [-s SOURCE] [-q SEARCH_QUERY]
                 [-ts START_QUERY] [-te END_QUERY] [-tl TIME_LIMIT]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any idea to solve this?&lt;BR /&gt;
Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2019 11:58:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483030#M193279</guid>
      <dc:creator>cpm003</dc:creator>
      <dc:date>2019-09-17T11:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Force python3 on custom commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483031#M193280</link>
      <description>&lt;P&gt;Splunk will support python3 in an upcoming release.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2019 13:28:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483031#M193280</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-09-17T13:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Force python3 on custom commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483032#M193281</link>
      <description>&lt;P&gt;&lt;A href="https://www.splunk.com/blog/2019/07/01/admins-and-developers-we-re-transitioning-to-python-3.html"&gt;https://www.splunk.com/blog/2019/07/01/admins-and-developers-we-re-transitioning-to-python-3.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2019 18:55:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483032#M193281</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2019-09-17T18:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Force python3 on custom commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483033#M193282</link>
      <description>&lt;P&gt;I have the same problem. It was working in 6.6 but not in 7.3.1&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 12:55:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483033#M193282</guid>
      <dc:creator>kiril123</dc:creator>
      <dc:date>2019-09-20T12:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Force python3 on custom commands</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483034#M193283</link>
      <description>&lt;P&gt;Hi , &lt;/P&gt;

&lt;P&gt;You can write a wrapper script to use the python3 available on your system to execute the custom commands.&lt;/P&gt;

&lt;P&gt;import os &lt;BR /&gt;
import subprocess&lt;/P&gt;

&lt;P&gt;_NEW_PYTHON_PATH = '/opt/rh/python27/root/usr/bin'&lt;BR /&gt;
_SPLUNK_PYTHON_PATH = os.environ['PYTHONPATH']&lt;/P&gt;

&lt;P&gt;os.environ['PYTHONPATH'] = _NEW_PYTHON_PATH &lt;BR /&gt;
my_process = os.path.join(os.getcwd(), 'test.py')&lt;/P&gt;

&lt;P&gt;p = subprocess.Popen([os.environ['PYTHONPATH'], my_process, _SPLUNK_PYTHON_PATH], &lt;BR /&gt;
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)&lt;BR /&gt;
output = p.communicate()[0]&lt;BR /&gt;
print output&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:19:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Force-python3-on-custom-commands/m-p/483034#M193283</guid>
      <dc:creator>nilendra19888</dc:creator>
      <dc:date>2020-09-30T02:19:45Z</dc:date>
    </item>
  </channel>
</rss>

