Building for the Splunk Platform

Getting errors when running in Splunk Python SDK.


We use Splunk cloud and I'm trying to figure out how to use the Splunk Python SDK but I'm stuck on the first example. When I first ran, I got the error:

NameError: name 'six' is not defined
Which I fixed by adding "as six" to "import splunklib.six.moves.http_client"

Now I'm stuck, getting the following when I enter python

Traceback (most recent call last):
File "", line 30, in 
connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
AttributeError: 'module' object has no attribute 'moves

Any thoughts?

Thank you.

Labels (2)
0 Karma


OK, this turned out to be a silly oversight. I had changed the "import" line, but then hadn't changed the actual connection definition is line 30 from:
connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
connection = six.HTTPSConnection(HOST, PORT)

Now that error is solved but I still can't seem to get connected via Python. I'm thinking I need to have greater permissions maybe? Here's the new traceback:

Traceback (most recent call last):
  File "", line 43, in 
    connection.request("POST", "/services/auth/login", body, headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1053, in request
    self._send_request(method, url, body, headers)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1093, in _send_request
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1049, in endheaders
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 893, in _send_output
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 855, in send
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 1274, in connect
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 352, in wrap_socket
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 579, in __init__
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/", line 808, in do_handshake
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)
0 Karma
Get Updates on the Splunk Community!

Ready, Set, SOAR: How Utility Apps Can Up Level Your Playbooks!

 WATCH NOW Powering your capabilities has never been so easy with ready-made Splunk® SOAR Utility Apps. Parse ...

DevSecOps: Why You Should Care and How To Get Started

 WATCH NOW In this Tech Talk we will talk about what people mean by DevSecOps and deep dive into the different ...

Introducing Ingest Actions: Filter, Mask, Route, Repeat

WATCH NOW Ingest Actions (IA) is the best new way to easily filter, mask and route your data in Splunk® ...