<?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: &amp;quot;ModuleNotFoundError: No module named 'syslog'&amp;quot; error on running python script in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/624370#M10865</link>
    <description>&lt;P&gt;Got a recommendation to use below app-&amp;nbsp;&lt;/P&gt;&lt;P&gt;splunkbase.splunk.com/app/4322&lt;/P&gt;</description>
    <pubDate>Thu, 15 Dec 2022 13:41:29 GMT</pubDate>
    <dc:creator>sutom</dc:creator>
    <dc:date>2022-12-15T13:41:29Z</dc:date>
    <item>
      <title>Why is there an error "ModuleNotFoundError: No module named 'syslog'" on running my python script?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620624#M10854</link>
      <description>&lt;P&gt;Dear All,&lt;/P&gt;
&lt;P&gt;I have created a TA to monitor a custom python script named log_parser_v1.py". Here is the configuration from /&lt;STRONG&gt;splunk/etc/apps/TA-logs/default/inputs.conf&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[script://./bin/log_parser_v1.py]
python.version = python3.9
interval = 300
disabled = false&lt;/LI-CODE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;But while running TA got failed with the error "ModuleNotFoundError: No module named 'syslog'"&lt;/P&gt;
&lt;P&gt;So I am trying to debug with splunk cmd python, and it's throwing "ModuleNotFoundError: No module named 'syslog'" error -&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[ss@localhost bin]$ ./splunk cmd python log_parser_v1.py
Traceback (most recent call last):
  File "bin/log_parser_v1.py", line 7, in &amp;lt;module&amp;gt;
    import syslog
ModuleNotFoundError: No module named 'syslog'&lt;/LI-CODE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;But the same script runs fine with the command &lt;STRONG&gt;python3.9 bin/log_parser_v1.py&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Here are the few lines from the script with the import statement of the module "syslog" in the line 7-&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[ss@localhost bin]$ cat log_parser_v1.py
#!/usr/bin/env python
import os, sys
sys.path.append('/usr/bin/python3.9')
sys.path.append('/usr/lib/python3.9/site-packages')
sys.path.append('/usr/lib64/python3.9/site-packages')
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import json, logging, syslog, datetime, argparse, shutil, zipfile, tarfile, bz2, socket, sys, errno, time, gzip, hashlib
from logging.handlers import SysLogHandler, SYSLOG_TCP_PORT
from syslog import LOG_USER&lt;/LI-CODE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;To use python3.9. I append the python3.9 package path in script but it still is not picking the syslog module. here is the python3.9 path -&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[ss@localhost bin]$ whereis python
python: /usr/bin/python2.7 /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3.9 /usr/lib/python2.7 /usr/lib/python3.6 /usr/lib/python3.9 /usr/lib64/python2.7 /usr/lib64/python3.6 /usr/lib64/python3.9 /usr/include/python3.9 /usr/include/python2.7 /usr/include/python3.6m /usr/share/man/man1/python.1.gz&lt;/LI-CODE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;I also tried to import syslog package with &lt;STRONG&gt;./splunk cmd python, &lt;/STRONG&gt;but it got failed&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[ss@localhost bin]$ ./splunk cmd python
Python 3.7.11 (default, May 25 2022, 12:23:55)
[GCC 9.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import sys
&amp;gt;&amp;gt;&amp;gt; import syslog
Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
ModuleNotFoundError: No module named 'syslog'
&amp;gt;&amp;gt;&amp;gt; exit()&lt;/LI-CODE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;And here is imported successfully with &lt;STRONG&gt;python3.9&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[ss@localhost bin]$ python3.9
Python 3.9.7 (default, Sep 13 2021, 08:18:39)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import syslog
&amp;gt;&amp;gt;&amp;gt; exit()&lt;/LI-CODE&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;Guys, I am looking for your help to understand like what is missing. please help here.&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 23:22:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620624#M10854</guid>
      <dc:creator>sutom</dc:creator>
      <dc:date>2022-12-01T23:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: "ModuleNotFoundError: No module named 'syslog'" error on running python script</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620630#M10855</link>
      <description>&lt;P&gt;Splunk runs Python scripts using its own Python interpreter.&amp;nbsp; If you develop code using a different interpreter, be sure to test with the Splunk interpreter to find out about errors like ths.&lt;/P&gt;&lt;P&gt;The fix is to add the missing module to the &lt;FONT face="courier new,courier"&gt;bin/lib&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;lib&lt;/FONT&gt; directory of your TA.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 17:12:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620630#M10855</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-11T17:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: "ModuleNotFoundError: No module named 'syslog'" error on running python script</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620633#M10856</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp; Thanks for the response.&lt;/P&gt;&lt;P&gt;But in the past, I had the same issue for another script with BeautifulSoup, and that got resolved by appending the python3.9 path&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sys.path.append('/usr/local/bin/python3.9')
sys.path.append('/usr/local/lib/python3.9/site-packages')
sys.path.append('/usr/lib64/python3.9/site-packages')
from bs4 import BeautifulSoup&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here Also, I thought it was a similar one. but not working...&lt;/P&gt;&lt;P&gt;Another analysis is that if I am running &lt;STRONG&gt;./splunk cmd python3.9&lt;/STRONG&gt; then syslog gets imported..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[ss@localhost bin]$./splunk cmd python3.9
Python 3.9.7 (default, Sep 13 2021, 08:18:39)
[GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
&amp;gt;&amp;gt;&amp;gt; import syslog
&amp;gt;&amp;gt;&amp;gt; exit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also if I run script manually with the command -&amp;nbsp;&lt;STRONG&gt;./splunk cmd python3.9 log_parser_v1.py&lt;/STRONG&gt;, it is running fine.&lt;/P&gt;&lt;P&gt;but It failing under the TA schedule.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 18:14:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620633#M10856</guid>
      <dc:creator>sutom</dc:creator>
      <dc:date>2022-11-11T18:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: "ModuleNotFoundError: No module named 'syslog'" error on running python script</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620637#M10857</link>
      <description>&lt;P&gt;I don't have a "python3.9" in my Splunk installation, just "python3".&lt;/P&gt;&lt;P&gt;According to the Admin manual, "python3.9" is not a valid value for &lt;FONT face="courier new,courier"&gt;python.version&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;If what you've done before isn't working this time then consider filing a support request.&amp;nbsp; While you wait for that, try my suggestion.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 19:37:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/620637#M10857</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-11-11T19:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: "ModuleNotFoundError: No module named 'syslog'" error on running python script</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/622909#M10858</link>
      <description>&lt;P&gt;At that point you're either importing modules across python versions or running a non-standard interpreter, both of which are unsupported and asking for trouble. I'd definitely recommend &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt; 's suggestion of having the package in the app's path.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 21:15:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/622909#M10858</guid>
      <dc:creator>terminaloutcome</dc:creator>
      <dc:date>2022-12-01T21:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: "ModuleNotFoundError: No module named 'syslog'" error on running python script</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/624370#M10865</link>
      <description>&lt;P&gt;Got a recommendation to use below app-&amp;nbsp;&lt;/P&gt;&lt;P&gt;splunkbase.splunk.com/app/4322&lt;/P&gt;</description>
      <pubDate>Thu, 15 Dec 2022 13:41:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-is-there-an-error-quot-ModuleNotFoundError-No-module-named/m-p/624370#M10865</guid>
      <dc:creator>sutom</dc:creator>
      <dc:date>2022-12-15T13:41:29Z</dc:date>
    </item>
  </channel>
</rss>

