All Apps and Add-ons

Python for Scientific Computing App: Error when importing pandas in my script

korst
Engager

I have installed the Python for Scientific Computing App into Splunk Enterprise. It seems to have installed correctly

PS: I use tgz to install Splunk Enterprice, version is 7.0.

Then, I try to execute command [ /opt/splunk/bin/splunk cmd python ]

import sys
sys.path.append('/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages')
import pandas

Traceback (most recent call last):

File "", line 1, in 
  File "/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/pandas/__init__.py", line 42, in 
    from pandas.core.api import *
  File "/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/pandas/core/api.py", line 10, in 
    from pandas.core.groupby import Grouper
  File "/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/pandas/core/groupby.py", line 50, in 
    from pandas.core.frame import DataFrame
  File "/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/pandas/core/frame.py", line 69, in 
    from pandas.core.generic import NDFrame, _shared_docs
  File "/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/pandas/core/generic.py", line 48, in 
    from pandas.io.formats.format import format_percentiles, DataFrameFormatter
  File "/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/pandas/io/formats/format.py", line 36, in 
    from pandas.io.common import (_get_handle, UnicodeWriter, _expand_user,
  File "/opt/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/pandas/io/common.py", line 6, in 
    import mmap
ImportError: No module named mmap

Please guide me how to add mmap or my steps are wrong, thank you~~orz

Tags (2)

badarsebard
Communicator

Based on the way you've imported pandas by adding the add-on site-packages directly to your system.path my best guess is the mmap module is somewhere else in the add-on not in site-packages. If you want to keep using the add-on you'll need to find the location of the other modules and add them to your path.

Alternatively, I've released a new app called PyDen on Splunkbase which lets a developer create Python virtual environments of varying versions (3.7, 3.5 - 3.7) which can be leveraged by custom scripts instead of the built-in Python Splunk uses. The app can also install PyPI packages to the environments allowing you to use any version of any libraries you'd like on any version of Python you need.

0 Karma
Get Updates on the Splunk Community!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...