Skip to content

Import Error due to API Change in pamqp>=3.0.0 (specification -> commands) #144

@ltiannan

Description

@ltiannan

Issue Description

When installing the latest amqpstorm (2.11.1) alongside pamqp>=3.0.0 (e.g., 3.3.0), an ImportError occurs. This is because pamqp renamed its specification module to commands starting from version 3.0.0, but amqpstorm still imports the old module name.

Error Message:
ImportError: cannot import name 'specification' from 'pamqp'

Root Cause

After inspecting the source code, I found that amqpstorm imports pamqp.specification in several files, such as amqpstorm/channel.py and amqpstorm/basic.py. According to the pamqp library's documentation, the public API modules were renamed in version 3.0.0:

  • Old (pamqp < 3.0.0): from pamqp import specification
  • New (pamqp >= 3.0.0): from pamqp import commands

Suggested Fix

Update the import statements in amqpstorm to be compatible with the newer pamqp API. This could be done by:

  1. Direct update: Replace from pamqp import specification with from pamqp import commands in the relevant files.
  2. Conditional import (for broader compatibility): Implement a try/except block to attempt importing the new name first, falling back to the old one. Example:
try:
    from pamqp import specification
except ImportError:
    from pamqp import commands as specification

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions