All Apps and Add-ons

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


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
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/", 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/", 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/", 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/", 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/", line 48, in 
    from 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/", line 36, in 
    from 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/", 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)


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
Register for .conf21 Now! Go Vegas or Go Virtual!

How will you .conf21? You decide! Go in-person in Las Vegas, 10/18-10/21, or go online with .conf21 Virtual, 10/19-10/20.