Python27 qpid : ImportError: No module named _cproton

标签 python amqp qpid

我尝试执行以下代码,但不幸的是我收到以下错误。任何建议都非常感激。 我在 c:\Python27\Lib\site-packages
中有以下文件 1) cproton.py
2)质子.py
3)_cproton.so

import sys
from cproton import *
from proton import *

#This code is for initiating the AMQP messenger
amqpmng = Messenger()
amqpmng._set_timeout(2000L) #Set timeout for sending and receiving at 2000 ms
address = "amqps://<<user>>:<<password>>@<<namespace>>.servicebus.windows.net/<<queue>>" 

#This code is for creating messages
msg = Message()
msg.subject = "This is a testmessage"
msg.body = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit."

#This code is for sending messages
try:
    msg.address = address
    amqpmng.put(msg)
    amqpmng.send()
except:
    e = sys.exc_info()[0]
    print e, "Waited for 2s to send messages, nothing send, connection timed out"

amqpmng.stop();

#This code is for receiving messages
amqpmng.subscribe(address)
amqpmng.start()
try:
    amqpmng.recv(1) #receive exactly 1 message (you can enter any value)
    msg = Message()
    while amqpmng.incoming > 0:
        amqpmng.get(msg)
        print(msg.body)
except:
    e = sys.exc_info()[0]
    print e, "Waited for 2s to receive messages, nothing received, connection timed out"

amqpmng.stop()

错误:

    Traceback (most recent call last):

    File "receiv.py", line 2, in <module> from cproton import *

    File "C:\Python27\lib\site-packages\cproton.py", line 29, in <module>
           _cproton = swig_import_helper()

    File "C:\Python27\lib\site-packages\cproton.py", line 21, in swig_import_helpe
           r

    import _cproton

    ImportError: No module named _cproton

最佳答案

.so 文件是在 UNIX 系统上使用的动态链接库。它不适用于 Windows。

除非您能找到预构建的 Windows 二进制文件,否则您必须自己编译它。您可以找到构建说明 here .

关于Python27 qpid : ImportError: No module named _cproton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25114183/

相关文章:

python 从列表中获取集合的两种方法中哪一种在效率方面更好?

jackson - 发送时在rabbitmq中设置消息头

message-queue - ZeroMQ、RabbitMQ 和 Apache Qpid 的性能比较

java - 编写无代理 AMQP 到 MQTT 适配器

python - Pandas GroupBy 在应用分位数后不保留吗?

python - 使用 python 和 GObject 自省(introspection)获取 GTK+ 主题颜色

python - 如何在任意位置插入元素到列表中?

RabbitMQ/AMQP - 微服务架构中队列/主题设计的最佳实践

具有多个 URI 的 RabbitMQ 连接

python - 通过 Service Bus Explorer 接收的 Azure 事件数据采用十六进制格式