[AttributeError:module'pika'在rabbitmq中没有属性'BlockingConnection'错误

问题描述 投票:2回答:1

最近我尝试使用pika库将队列作为rabitmq(rabbitmq_tutorials_partOne)的文档,我输入了此代码:

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='',
                  routing_key='hello',
                  body='Hello World!')
print(" [x] Sent 'Hello World!'")

connection.close()

但是我遇到此错误:

AttributeError: module 'pika' has no attribute 'BlockingConnection'

我安装的pika版本是:0.12.0。我使用此命令来安装pika:pip3 install pika。我不知道我的问题是什么。有什么办法可以解决这个问题?

python python-3.x rabbitmq queue pika
1个回答
0
投票

相对类似的问题:

模块'pika'没有属性'URLParameters'

无法理解。

© www.soinside.com 2019 - 2024. All rights reserved.