pyasn1-modules
raw JSON → 0.4.2 verified Tue May 12 auth: no python install: verified quickstart: stale
pyasn1-modules is a collection of ASN.1-based protocol modules for Python, built upon the pyasn1 library. The current version is 0.4.2, released on March 28, 2025. The library is actively maintained, with updates addressing compatibility and support for newer Python versions.
pip install pyasn1-modules Common errors
error ModuleNotFoundError: No module named 'pyasn1_modules' ↓
cause The `pyasn1-modules` package is not installed in the current Python environment or a specific sub-module cannot be found due to an incomplete installation or environment issue.
fix
Ensure
pyasn1-modules is installed: pip install pyasn1-modules. If using a specific protocol module, ensure it's imported correctly, e.g., from pyasn1_modules import rfc2459. error pkg_resources.DistributionNotFound: The 'pyasn1-modules>=0.2.1' distribution was not found and is required by google-auth ↓
cause A dependency, often `google-auth`, requires a specific version of `pyasn1-modules` that is either not installed, or `pkg_resources` cannot locate it due to conflicts, often when using `conda` alongside `pip` or having multiple Python installations.
fix
Force reinstall
pyasn1-modules and potentially pyasn1 to resolve potential conflicts: pip install --upgrade --force-reinstall pyasn1 pyasn1-modules. If using conda, consider creating a new environment and installing dependencies solely with pip or ensuring conda and pip are in sync. error TypeError: __init__() got an unexpected keyword argument 'openType' ↓
cause This error typically occurs due to an incompatibility between the installed versions of `pyasn1` and `pyasn1-modules`, where `pyasn1-modules` is trying to use an API feature (like `openType`) that is not present or has changed in the installed `pyasn1` version.
fix
Upgrade both
pyasn1 and pyasn1-modules to their latest compatible versions: pip install --upgrade pyasn1 pyasn1-modules. error pyasn1.error.PyAsn1Error: Component type not defined ↓
cause This error occurs during decoding when an ASN.1 sequence or set has components that are not explicitly defined in the `asn1Spec` provided to the decoder, making it unable to determine the type of the encountered data.
fix
Ensure that the
asn1Spec passed to the decoder.decode() function fully defines all potential components and their types within the ASN.1 structure being decoded. Explicitly define each component type within the Sequence or Set object that acts as the asn1Spec. error pyasn1.error.PyAsn1Error: 'not in asn1Spec: None' ↓
cause This error indicates that the `pyasn1` decoder was unable to match a tag from the incoming BER/DER/CER serialized data with any of the expected ASN.1 types defined in the `asn1Spec` provided, often because the `asn1Spec` is missing or incomplete for the data being decoded.
fix
Provide a complete and correct
asn1Spec (an ASN.1 type object from pyasn1 or pyasn1-modules) to the decoder.decode() function that accurately reflects the structure of the data being deserialized. For custom types, ensure they are correctly tagged and passed to the decoder. Warnings
breaking Dropped support for Python 2.7, 3.6, and 3.7 in version 0.4.0. ↓
fix Upgrade your Python environment to version 3.8 or later.
gotcha Importing modules directly without the pyasn1_modules prefix will result in ImportError. ↓
fix Use the correct import statement: from pyasn1_modules import <module_name>.
gotcha Ensure that pyasn1 is installed, as it is a required dependency. ↓
fix Install pyasn1 using pip install pyasn1.
breaking The pyasn1 decoder encountered an unexpected ASN.1 tag during decoding. This typically indicates that the input DER-encoded data does not conform to the specified ASN.1 schema (e.g., rfc2459.Certificate), or that the data itself is malformed. This can also occur if the version of pyasn1-modules providing the schema is incompatible with the structure of the data. ↓
fix Verify the integrity and correctness of the input DER-encoded data. Ensure it strictly adheres to the X.509 (RFC 2459) standard if `rfc2459.Certificate()` is used. Update both `pyasn1` and `pyasn1-modules` to their latest stable versions (`pip install --upgrade pyasn1 pyasn1-modules`) to ensure compatibility with modern certificate structures, or if parsing a non-standard certificate, ensure the correct `asn1Spec` is provided.
breaking Decoding a DER-encoded object with an incorrect ASN.1 schema or a malformed input will result in a 'pyasn1.error.PyAsn1Error' indicating 'TagSet not in asn1Spec'. ↓
fix Ensure that the DER-encoded input data is valid and conforms to the expected ASN.1 schema. Verify that the 'asn1Spec' provided to the decoder (e.g., 'decoder.decode(data, asn1Spec=...)') accurately represents the structure of the input data. Inspect the 'TagSet' mentioned in the error message to understand where the mismatch occurs, as it often points to an unexpected ASN.1 type or structure in the input.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.07s 20.5M
3.10 slim (glibc) - - 0.04s 21M
3.11 alpine (musl) - - 0.10s 23.1M
3.11 slim (glibc) - - 0.07s 24M
3.12 alpine (musl) - - 0.08s 14.9M
3.12 slim (glibc) - - 0.08s 15M
3.13 alpine (musl) - - 0.07s 14.5M
3.13 slim (glibc) - - 0.07s 15M
3.9 alpine (musl) - - 0.06s 20.1M
3.9 slim (glibc) - - 0.07s 21M
Imports
- rfc2459 wrong
import rfc2459correctfrom pyasn1_modules import rfc2459
Quickstart stale last tested: 2026-04-23
from pyasn1_modules import rfc2459
from pyasn1.codec.der import decoder
# Example DER-encoded certificate (incomplete for brevity)
der_encoded_cert = b'...'
# Decode the certificate
cert, _ = decoder.decode(der_encoded_cert, asn1Spec=rfc2459.Certificate())
# Access certificate fields
subject = cert['tbsCertificate']['subject']
print('Subject:', subject)