Splunk Search

python3.7, splunk 8.0, OS-RHEL8, when running scripted input getting error import BS4

mohammadsharukh
Path Finder

Change the python varaible to phython3 and ran the following commnad

dnf install python3-pip
dnf install python3-beautifulsoup4
pip3 install --user BeautifulSoup4

tried for a scripted input but getting the following error

01-26-2020 18:00:29.522 +0000 ERROR ExecProcessor - message from "/opt/splunk/bin/python3.7 /opt/splunk/etc/apps/search/bin/cric.py" import bs4
01-26-2020 18:00:29.522 +0000 ERROR ExecProcessor - message from "/opt/splunk/bin/python3.7 /opt/splunk/etc/apps/search/bin/cric.py" ModuleNotFoundError: No module named 'bs4'

How to import BS4

Tags (1)
0 Karma

MuS
Legend

Hi mohammadsharukh,

most likely you installed the module in your system library which is not used by Splunk. If I want to use a special python module I put it in $SPLUNK_HOME/etc/apps/YourAppNameHere/bin and load it from my script in the same directory.

You can manually check if this works by running these commands:

/opt/splunk/bin/splunk cmd /bin/bash
cd $SPLUNK_HOME/etc/apps/YourAppNameHere/bin
$SPLUNK_HOME/bin/splunk cmd python
import moduleNameHere

if this works without error messages you're all good to go, otherwise check what the error states (like missing dependencies and things)

Hope this helps ...

cheers, MuS

0 Karma
Get Updates on the Splunk Community!

Pro Tips for First-Time .conf Attendees: Advice from SplunkTrust

Heading to your first .Conf? You’re in for an unforgettable ride — learning, networking, swag collecting, ...

Raise Your Skills at the .conf25 Builder Bar: Your Splunk Developer Destination

Calling all Splunk developers, custom SPL builders, dashboarders, and Splunkbase app creators – the Builder ...

Hunt Smarter, Not Harder: Discover New SPL “Recipes” in Our Threat Hunting Webinar

Are you ready to take your threat hunting skills to the next level? As Splunk community members, you know the ...