Other Usage

Getting errors while importing python Splunk modules.

Prathyusha891
Explorer

Getting below errors while importing splunklib and splunk-sdk python packages. Any resolutions please?

Building wheels for collected packages: pycrypto
Building wheel for pycrypto (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for pycrypto (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [28 lines of output]
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
winrand.c

............

 

[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pycrypto
Failed to build pycrypto
ERROR: Could not build wheels for pycrypto, which is required to install pyproject.toml-based projects

0 Karma

marnall
Builder

It seems that splunklib is trying to get the obsolete pycrypto library. Ideally you should configure it to use the Cryptography or pycrypodome library.

There is an answer here how to change splunklib to use pycryptodome: https://stackoverflow.com/questions/59104347/how-do-i-install-splunklib-for-python-3-7-on-windows

In case that link goes down, here are the instructions:

by Chris Chris Dec 2 2019, 8:42:

I finally found the way to install it:

Uninstall pycrypto

pip uninstall pycrypto

Install pycryptodome as replacement of pycypto

pip install pycryptodome

Install splunklib without dependencies

pip install splunklib --no-deps

Edit "pythonlib"\splunklib-1.0.0.dist-info\METADATA and replace "Requires-Dist: pycrypto" with "Requires-Dist: pycryptodome"

install splunk-sdk

pip install splunk-sdk

check that everything is ok

pip install splunklib

 

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...