【发布时间】:2018-05-18 05:23:06
【问题描述】:
编辑:我的设备上安装了错误版本的 pika 软件包。我从 pip 更新后它工作正常。
我刚开始通过关注他们的tutorial 学习 RabbitMQ(使用 Python)的用法。 send.py 代码工作正常,但是当我尝试运行 receive.py 时,我看到了这个错误:
Traceback (most recent call last):
File "receive.py", line 15, in <module>
no_ack=True)
TypeError: basic_consume() got multiple values for keyword argument 'queue'
这是receive.py里面的代码:
#!/usr/bin/env python
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(callback,
queue='hello',
no_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
知道我做错了什么吗?
【问题讨论】:
-
你能显示你的代码吗?你在哪里使用 basic_consume()
-
是的,添加了。我以为我不需要,因为它在网站上。对此感到抱歉。
-
@sudhavna 我运行你的代码,它可以工作
-
您的回溯声称该文件名为
receieve.py,您声称其名为receive.py...确定您正在编辑正确的文件吗? -
糟糕。命名我的文件时出现拼写错误。但是,是的,我正在编辑同一个文件。