我被困在这个错误,我没有设法修复。我已经找到了相关的案例,但我很难将其应用到我自己的问题上。 有人能帮我理解为什么会发生这种类型错误和/或帮我找到解决方案吗?(请作为初学者回复我)
我在raspberry pi和pika 1.1.0中使用python
这是我的回溯:
File "amqp.py", line 33, in <module>
no_ack=True)
TypeError: basic_consume() got multiple values for keyword argument 'queue
我认为这就是相关代码:
def callback(ch, method, properties, body):
printer.inverseOn()
printer.println(' ' + '{:<31}'.format("TXT MESSAGE"))
printer.inverseOff()
printer.println(body)
printer.feed(3)
print("complete")
print " [x] Received %r" % (body)
channel.basic_consume(callback,
queue='texts',
no_ack=True)
如果有趣的话,这就是.py的其余部分
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
import pika, os, sys
from Adafruit_Thermal import *
printer = Adafruit_Thermal("/dev/serial0", 19200, timeout=5)
url_str = os.environ.get('CLOUDAMQP_URL','amqp://xxxxx')
url = urlparse(url_str)
params = pika.ConnectionParameters(host=url.hostname, virtual_host=url.path[1:],
credentials=pika.PlainCredentials(url.username, url.password))
connection = pika.BlockingConnection(params)
channel = connection.channel()
channel.queue_declare(queue='texts')
def callback(ch, method, properties, body):
printer.inverseOn()
printer.println(' ' + '{:<31}'.format("TXT MESSAGE"))
printer.inverseOff()
printer.println(body)
printer.feed(3)
print("complete")
print " [x] Received %r" % (body)
channel.basic_consume(callback,
queue='texts',
no_ack=True)
try:
channel.start_consuming()
except KeyboardInterrupt:
print "Break detected"
channel.stop_consuming()
connection.close()
sys.exit()
不确定你使用的是哪种皮卡版本;但根据[1],回调参数是第二个参数。队列参数是第一个。i、 e
channel.basic_consume("texts", callback, no_ack=True)
[1]-https://pika.readthedocs.io/en/stable/modules/adapters/blocking.html#pika.adapters.blocking_connection.BlockingChannel
相关问题 更多 >
编程相关推荐