Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery + SQS - pycurl error

Today I have been trying to setup Celery using AWS SQS as the broker, however upon excututing the following:

test.py

from celery import Celery

access_key_id = '********************'
secret_access_key = '****************************************'

broker_url = 'sqs://%s:%s@' %(access_key_id, secret_access_key)

app = Celery('test', backend=None, broker=broker_url)

@app.task
def add(x, y):
    return x + y

Attempting to run the Celery worker using the command

celery -A test worker --loglevel=info

With this I get the following error:

Unrecoverable error: ImportError('The curl client requires the pycurl library.',)

I have the following packages installed:

amqp (2.2.2)
billiard (3.5.0.3)
boto (2.48.0)
boto3 (1.4.7)
botocore (1.7.48)
celery (4.1.0)
docutils (0.14)
jmespath (0.9.3)
kombu (4.1.0)
pip (9.0.1)
pycurl (7.43.0)
python-dateutil (2.6.1)
pytz (2017.3)
s3transfer (0.1.11)
schedule (0.5.0)
setuptools (37.0.0)
six (1.11.0)
vine (1.1.4)
wheel (0.30.0)

Can anyone see what I am doing wrong? Thanks in advance!

like image 589
AndrewR Avatar asked Nov 21 '17 23:11

AndrewR


People also ask

What is the latest version of pycurl in the celery[SQS]bundle?

When you install the celery[sqs]bundle (currently version 4.1.0) with pip, it will also install the latest version of PycURLwhich Kombuuses for communicating over HTTP. On my fresh install of macOS however, starting the Celery worker would raise the following error: ImportError: The curl client requires the pycurl library.

Does pycurl work with celery on macOS High Sierra?

Chi Shang Cheng Installing PycURL on macOS High Sierra January 26, 2018 I’m working on a Django project where we use Amazon SQSas broker for Celery. When you install the celery[sqs]bundle (currently version 4.1.0) with pip, it will also install the latest version of PycURLwhich Kombuuses for communicating over HTTP.

How to connect to AWS SQS service from within celery?

Celery would automatically connect to AWS SQS service given AWS service keys are available in the environment variables. The queue_name_prefix would allow you to create/use separate queues for different environments, e.g prod- {queue_name}, dev- {queue_name}

What is celery in Python?

Celery is a great and simple Task… | by Edison Wang | Python in Plain English Celery is a great and simple Task Queueing system for Python. It allows you to offload heavy tasks to another server and run it asynchronously. It can also run periodic tasks too.


2 Answers

I had the same error and these steps worked for me:

mac:

brew upgrade openssl

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"   

export PYCURL_SSL_LIBRARY=openssl

python -m pip install celery[sqs]

centos:

pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
pip install --compile pycurl
like image 113
BlaShadow Avatar answered Oct 05 '22 07:10

BlaShadow


Looks like it could be an issue with the version of Celery (4.1.0) that you have. If I execute the same code after downgrading to version 3.1.25 it works fine.

like image 30
Sudhi Pulla Avatar answered Oct 05 '22 06:10

Sudhi Pulla