Skip to content

incompatible with Python 3.13 due to pgpy dependency using deprecated imghdr module #168

@SmileyChris

Description

@SmileyChris

The cybersource-rest-client-python package fails to initialize on Python 3.13 due to a transitive dependency issue with the pgpy package.
See also: SecurityInnovation/PGPy#462

Environment

  • Package version: 0.0.70 (latest)
  • Python version: 3.13.x
  • Operating System: All platforms

Root Cause

  1. Python 3.13 removed the deprecated imghdr module (https://peps.python.org/pep-0594/)
  2. The pgpy package (v0.6.0) imports imghdr in its constants.py file
  3. cybersource-rest-client-python depends on pgpy (defined in setup.py)
  4. BatchUploadWithMTLSApi is imported in the top-level CyberSource/__init__.py
  5. This triggers the import chain: CyberSource → BatchUploadWithMTLSApi → PgpEncryption → pgpy → imghdr ❌

Error Traceback

  import CyberSource

  File "/site-packages/CyberSource/__init__.py", line 1559, in <module>
      from .api.o_auth_api import OAuthApi
  File "/site-packages/CyberSource/api/__init__.py", line 5, in <module>
      from .batch_upload_with_mtls_api import BatchUploadWithMTLSApi
  File "/site-packages/CyberSource/api/batch_upload_with_mtls_api.py", line 6, in <module>
      from CyberSource.utilities.pgpBatchUpload.pgp_encryption import PgpEncryption
  File "/site-packages/CyberSource/utilities/pgpBatchUpload/pgp_encryption.py", line 4, in <module>
      import pgpy
  File "/site-packages/pgpy/__init__.py", line 4, in <module>
      from .pgp import PGPKey
  File "/site-packages/pgpy/pgp.py", line 25, in <module>
      from .constants import CompressionAlgorithm
  File "/site-packages/pgpy/constants.py", line 5, in <module>
      import imghdr
  ModuleNotFoundError: No module named 'imghdr'

Impact

  • Blocks Python 3.13 adoption for all users of this package
  • Affects all users, even those not using batch upload functionality, because the import happens at package initialization

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions