Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

SNMP library for Python

PyPI Python Versions CI GitHub license

This is a pure-Python, open source and free implementation of v1/v2c/v3 SNMP engine distributed under 2-clause BSD license.

The PySNMP project was initially sponsored by a PSF grant. Thank you!

This version is a fork of Ilya Etingof deceased's project etingof/pysnmp. Ilya sadly passed away on 10-Aug-2022. Announcement here. His work is still of great use to the Python community and he will be missed.

Features

  • Complete SNMPv1/v2c and SNMPv3 support
  • SMI framework for resolving MIB information and implementing SMI Managed Objects
  • Complete SNMP entity implementation
  • USM Extended Security Options support (3DES, 192/256-bit AES encryption)
  • Extensible network transports framework (UDP/IPv4, UDP/IPv6)
  • Asyncio integration
  • pysmi integration for dynamic MIB compilation
  • Built-in instrumentation exposing protocol engine operations
  • 100% Python, supports Python 3.10 and later
  • MT-safe (if SnmpEngine is thread-local)

Features, specific to SNMPv3 model include:

  • USM authentication (MD5/SHA-1/SHA-2) and privacy (DES/AES) protocols (RFC3414, RFC7860)
  • View-based access control to use with any SNMP model (RFC3415)
  • Built-in SNMP proxy PDU converter for building multi-lingual SNMP entities (RFC2576)
  • Remote SNMP engine configuration
  • Optional SNMP engine discovery
  • Shipped with standard SNMP applications (RC3413)

Download & Install

The PySNMP software is freely available for download from PyPI and GitHub.

Just run:

$ pip install pysnmplib

That pulls in what an SNMP engine needs to run:

  • PyASN1
  • PyCryptodomex (required for SNMPv3 encryption; imported lazily, so SNMPv1, SNMPv2c and the SNMPv3 noAuthNoPriv/authNoPriv security levels work without it)

pysmi is not pulled in. It compiles ASN.1 MIB sources at run time, which some deployments do and most do not, so it is an extra:

$ pip install 'pysnmplib[compile]'

Without it everything except run-time MIB compilation works — including SNMPv3, name resolution and the standard MIBs an engine needs, which PySNMP ships. Asking for a MIB compiler when the extra is not installed raises SmiError naming the missing import.

MIB content is a separate thing again, and not a pip install: module definitions come from the MIB distribution, used live over HTTPS or installed locally from a release archive or an OCI image. PySNMP starts without it, on the standard modules it ships.

Examples

PySNMP is designed in a layered fashion. Top-level and easiest to use API is known as hlapi. Here's a quick example on how to SNMP GET:

from pysnmp.hlapi import *

iterator = getCmd(
    SnmpEngine(),
    CommunityData("public"),
    UdpTransportTarget(("localhost", 161)),
    ContextData(),
    ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr", 0)),
)

errorIndication, errorStatus, errorIndex, varBinds = next(iterator)

if errorIndication:  # SNMP engine errors
    print(errorIndication)
else:
    if errorStatus:  # SNMP agent errors
        print(
            "%s at %s"
            % (
                errorStatus.prettyPrint(),
                varBinds[int(errorIndex) - 1] if errorIndex else "?",
            )
        )
    else:
        for varBind in varBinds:  # SNMP response contents
            print(" = ".join([x.prettyPrint() for x in varBind]))

This is how to send SNMP TRAP:

from pysnmp.hlapi import *

errorIndication, errorStatus, errorIndex, varBinds = next(
    sendNotification(
        SnmpEngine(OctetString(hexValue="8000000001020304")),
        UsmUserData(
            "usr-sha-aes128",
            "authkey1",
            "privkey1",
            authProtocol=usmHMACSHAAuthProtocol,
            privProtocol=usmAesCfb128Protocol,
        ),
        UdpTransportTarget(("localhost", 162)),
        ContextData(),
        "trap",
        NotificationType(ObjectIdentity("SNMPv2-MIB", "authenticationFailure")),
    )
)

if errorIndication:
    print(errorIndication)
$ python3 examples/hlapi/asyncio/manager/cmdgen/v1-get.py
SNMPv2-MIB::sysDescr.0 = Linux localhost 5.15.0
$
$ python3 examples/hlapi/asyncio/agent/ntforg/default-v1-trap.py
SNMPv2-MIB::sysUpTime.0 = 0
SNMPv2-MIB::snmpTrapOID.0 = SNMPv2-MIB::warmStart
SNMPv2-MIB::sysName.0 = system name

Other than that, PySNMP is capable to automatically fetch and use required MIBs from HTTP, FTP sites or local directories. You could configure any MIB source available to you (including the MIB distribution) for that purpose.

For more example scripts please refer to the examples/ directory in this repository.

Documentation

The rendered documentation is at https://pysnmp.github.io/pysnmp/, built from the docs/ directory in this repository. The organization site describes how pysnmp, the MIB distribution, pysmi and pyasn1 fit together.

If something does not work as expected, please open an issue at GitHub or post your question on Stack Overflow.

Bug reports and PRs are appreciated! ;-)

Copyright (c) 2005-2019, Ilya Etingof deceased. All rights reserved.

Release files for pysnmplib 6.0.0rc16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysnmplib 6.0.0rc16
File Size Uploaded
pysnmplib-6.0.0rc16.tar.gz 778.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pysnmplib 6.0.0rc16
File Interpreter ABI Platform
pysnmplib-6.0.0rc16-py3-none-any.whl Python 3 none any Details

Total release size: 1.2 MB

Release files / pysnmplib-6.0.0rc16.tar.gz

Download URL pysnmplib-6.0.0rc16.tar.gz
Size 778.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2cda3cc3c979f5365cf3652d2ec5baebb4032213be266e28518395d7a5957640
BLAKE2b-256 checksum
How to use checksums
78fd1e970149a547641458be9a9fe4d96a893f7527b176c326d18078b1d31cb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / pysnmplib-6.0.0rc16-py3-none-any.whl

Download URL pysnmplib-6.0.0rc16-py3-none-any.whl
Size 409.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f95e957e0727bc35c9b7eab73751af4a99338691cdd574ab42ddd628619afad
BLAKE2b-256 checksum
How to use checksums
a9c40f4462c3c0c0ca9a016664643775807fbebc801894bc3d61d56f91485312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

6.0.0rc16 This release

2 release files

5.0.25

2 release files

5.0.24

2 release files

5.0.23

2 release files

5.0.22

2 release files

5.0.21

2 release files

5.0.20

2 release files

5.0.19

2 release files

5.0.16

2 release files

5.0.15

2 release files

5.0.9

2 release files

5.0.8

2 release files

5.0.7

2 release files

5.0.6

2 release files

5.0.5

2 release files

5.0.4

2 release files

5.0.3

2 release files

5.0.2

2 release files

5.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page