python-3.xmacospycharmsplunk-sdk

PyCharm doesn't Splunk SDK (splunklib)


I have a simple python script that calls the Splunk API. For this, I include splunklib: "import splunklib.client as client"

This script works very well, when I start it from a terminal window (MacOS): python3 main.py

For this, I had to install splunklib using "pip3 install splunklib".

Unfortunately I can't run the same script out of Pycharm. I also successfully installed splunklib under settings/Project Interpreter/Package. splunklib is shown in the list of installed packages for the Project Interpreter (splunklib 1.0.0, Python 3.7).

When I run the script using Pycharm, I get the following error message:

import splunklib.client as client ModuleNotFoundError: No module named 'splunklib.client'; 'splunklib' is not a package

Why can Pycharm not find Esplunklib, even though it's installed in the Project Interpreter?


Solution

  • I had this same issue today, and tried to resolve it the same as you by doing a pip3 install splunklib. Unfortunately, the splunklib package is not the one you want. I'm not sure if that is a deprecated package, or something else entirely, but what you're probably looking for is the splunk-sdk.

    This should get you going; pip3 install splunk-sdk