4
votes

Going through the Rabbit MQ Pika HelloWorld tutorial found here: https://www.rabbitmq.com/tutorials/tutorial-one-python.html

The problem is, I keep getting this error whenever I run my receive script:

Traceback (most recent call last):
  File "receive.py", line 5, in <module>
    pika.ConnectionParameters(host='localhost'))

  File "C:\Users\Colin Warn\PycharmProjects\untitled2\venv\lib\site-packages\pika\adapters\blocking_connection.py", line 360, in __init__
    self._impl = self._create_connection(parameters, _impl_class)

  File "C:\Users\Colin Warn\PycharmProjects\untitled2\venv\lib\site-packages\pika\adapters\blocking_connection.py", line 451, in _create_connection
 
raise self._reap_last_connection_workflow_error(error)

pika.exceptions.AMQPConnectionError

Here's the code I'm attempting to run:

#!/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(
    queue='hello', on_message_callback=callback, auto_ack=True)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()

Any help is much appreciated. Thank you so much in advance.

2
Do you have a rabbit server running in your machine? - julian salas
Not sure how to check. I've also recreated their send.py script that I thought would create one, but it just sends me the same error. I have more than 200 MB on my disk drive, so I'm not sure what else would be causing this. - Colin Warn
You have to install a rabbit in your machine check out this rabbitmq.com/download.html after installing rabbit server go back and rerun the script. I hope it goes well. - julian salas
That fixed it, thank you! - Colin Warn

2 Answers

5
votes

All you need to install RabbitMQ in your PC, You can simply run with docker using below command in another terminal, and re run your code

docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
4
votes

You need to install RabbitMQ on your machine: https://rabbitmq.com/download.html

After installing RabbitMQ server re-run the script.