Archive
Highlighted

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

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/SplunkSAScientificPythonlinuxx8664/bin/linuxx8664/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)
Highlighted

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

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