Splunk Dev

Error when import numpy in my script ?

heshamzaid
Explorer

i installed python Splunk_SA_Scientific_Python_linux_x86_64 to import numpy module and follow the instruction in readme file but i got this error :
Traceback (most recent call last):
File "test.py", line 4, in
import numpy as np
File "/splunk/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/numpy/init.py", line 180, in
from . import add_newdocs
ImportError: cannot import name add_newdocs

Tags (2)
0 Karma

jkat54
SplunkTrust
SplunkTrust

Do you have add_newdocs.py in this directory?

 /splunk/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/numpy/

If not, that's the cause.

Another possibility is that maybe these files are owned by someone other than the splunk user? The below might fix it:

 chown -Rf splunk.  /splunk/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/
0 Karma

jkat54
SplunkTrust
SplunkTrust

It's possible that something else you imported prior has already imported a module named add_newdocs.

What happens if you remove previous imports in test.py?

0 Karma

heshamzaid
Explorer

i have the add_newdocs.py file in /splunk/splunk/etc/apps/Splunk_SA_Scientific_Python_linux_x86_64/bin/linux_x86_64/lib/python2.7/site-packages/numpy

and its own to the splunk user

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...