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/__init__.py", 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 setup.py 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/program.py", line 22, in <module>
import pandas
File "/splunk/lib/python3.7/site-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import (
File "/splunk/lib/python3.7/site-packages/pandas/compat/__init__.py", line 14, in <module>
from pandas._typing import F
File "/splunk/lib/python3.7/site-packages/pandas/_typing.py", 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 exec_anaconda.py to my app's bin.
2. Putting the following code at the very top of my script:
#!/usr/bin/python
import exec_anaconda
exec_anaconda.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.