python - AttributeError:模块'pika'在rabbitmq中没有属性'BlockingConnection'错误
问题描述
最近我尝试使用 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'
我安装的鼠兔版本是:0.12.0。我用这个命令安装 pika : pip3 install pika
。我无法意识到我的问题是什么。有没有什么办法解决这一问题?
解决方案
推荐阅读
- django - Django:避免在模板中呈现为变量
- python - Pandas:将多索引级别转换为一组新的列
- python - pd.to_datetime 好的,但仍然不是情节中的日期
- android - 按钮未填充父容器高度
- python - 使用 pyinstaller 转换为 exe 时出现 Moviepy 模块错误
- azure - 在 azure blob 存储容器中,我可以使搜索功能(文件夹)不区分大小写吗
- css - CSS 视差:“溢出:隐藏;” 在 iOS 上打破 3D 变换/透视
- kotlin - 如何在 Kotlin 中使用 okhttp3 进行气流实验 api?
- node.js - 如何修复 NPM
- node.js - 使用反应和节点的 PUT 请求错误( net::ERR_CONNECTION_RESET )