import pika auth = pika.PlainCredentials('admin', 'zyj@1985724') connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.137.10',port=5672,virtual_host= '/', credentials=auth)) channel = connection.channel() channel.queue_declare(queue='TEST01') def callback(ch, method, properties, body): print(" [x] Received %r" % body) channel.basic_consume(on_message_callback=callback, queue='TEST01', auto_ack=True) print(' [*] Waiting for messages. To exit press CTRL+C') channel.start_consuming()