- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Splunk python3 can't work import pandas
How should I do?
sample:
% $SPLUNK_HOME/bin/splunk cmd python3
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pandas'
and how does custom apps use python3?
where should I put on python.version=python3
?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try manually downloading pandas and copy them to Splunk\etc\apps\<APP>\bin
folder then in script that you have in that bin folder, for example Splunk\etc\apps\<APP>\bin\main.py
add following:
import sys
sys.path.append('./pandas')
sys.path.insert(0, './pandas')
It is lazy workaround but importing should now work.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In most cases this error in Python generally raised:
- You haven't installed Pandas explicitly with pip install pandas.
- You may have different Python versions on your computer and Pandas is not installed for the particular version you're using.
You can run the following command in your Linux/MacOS/Windows terminal.
pip install pandas
To be sure you are not having multiple Python versions that are confusing, you should run following commands:
python3 -m pip install pandas
python3 -c 'import pandas'
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try manually downloading pandas and copy them to Splunk\etc\apps\<APP>\bin
folder then in script that you have in that bin folder, for example Splunk\etc\apps\<APP>\bin\main.py
add following:
import sys
sys.path.append('./pandas')
sys.path.insert(0, './pandas')
It is lazy workaround but importing should now work.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I tried this work around for pandas.
but i am getting the below error while calling pandas.
Traceback (most recent call last):
File "sample.py", line 38, in <module>
df = pandas.DataFrame(data)
NameError: name 'pandas' is not defined
while i added syspath append and insert, i removed import pandas from the python file.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@seva98
thank you. I can't find this solution.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @to4kawa,
I think the pandas module wasn't properly installed. Can you list your steps and reference to the documentation you've used to install pandas python module?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi @PaveIP
!#/usr/bin/env python
It run with python in my OS(e.g. Anaconda) . I can use pandas
,also.
I'm trying to publish Apps, and considering windows, if pandas
can be used with Splunk's standard python, I'm trying to change to that method like following:
!#$SPLUNK_HOME/bin/python3
However, I have not found it yet. Should I copy Python for Scientific Computing/exec_anaconda.py ?
reference: https://github.com/splunk/Splunk-python-for-scientific-computing/tree/master/package
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not sure, that can work
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @PaveIP
No problem.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sample usage:
[freqserver]
external_cmd = freq.py domain
external_type = python
python.version = python2
fields_list = domain, frequency
