All Apps and Add-ons

Why do I keep getting errors when trying to import Pandas with Splunk's python?

New Member

I am trying to import Pandas in a Splunk app that I am developing. The app also contains fpdf to create a pdf and insert the images that are produced using Pandas.  2 of the 3 solutions that I tried produce an error as soon as I put 'import pandas'.

1. Solution 1: importing the Pandas module from a copy of the module that is located in the App's bin directory.

The error log says:

File "../splunk/etc/apps/<Appname>/bin/pandas/", line 37, in <module>
f"C extension: {module} not built. If you want to import "
ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built. If you want to import pandas from the source directory, you may need to run 'python build_ext --inplace --force' to build the C extensions first.

2. Solution 2: Just import the splunk lib from Splunk's Python (simply by putting 'import pandas' at the top of the code).

The error log says:

Traceback (most recent call last):
File "/splunk/etc/apps/<Appname>/bin/", line 22, in <module>
import pandas
File "/splunk/lib/python3.7/site-packages/pandas/", line 22, in <module>
from pandas.compat import (
File "/splunk/lib/python3.7/site-packages/pandas/compat/", line 14, in <module>
from pandas._typing import F
File "/splunk/lib/python3.7/site-packages/pandas/", line 12, in <module>
from mmap import mmap
ModuleNotFoundError: No module named 'mmap'

For the third and final attempt to make it work, I tried using a solution that I found in Splunk's forum, which is by using the app "Python for Scientific Computing". The steps that I have applied were:

1. Coping to my app's bin.

2. Putting the following code at the very top of my script:

import exec_anaconda
# Put the rest of your imports below, e.g.:
import numpy as np

import pandas

What happens with this solution is that I get no more error on the 'import pandas', but I get errors from most of the other modules that I am working with (fpdf, pip and so on).

Does anybody know how to import pandas without getting these kind of errors?

Thank you very much.

Labels (2)
Tags (3)
0 Karma
Get Updates on the Splunk Community!

Platform Newsletter Highlights | March 2023

 March 2023 | Check out the latest and greatestIntroducing Splunk Edge Processor, simplified data ...

Enterprise Security Content Updates (ESCU) - New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 3 releases of new content via the Enterprise ...

Thought Leaders are Validating Your Hard Work and Training Rigor

As a Splunk enthusiast and member of the Splunk Community, you are one of thousands who recognize the value of ...