Whenever I start celery worker in my django project, it fails to start with the following error:
"Unrecoverable error: ImportError('The curl client requires the pycurl library.')
I have visited all the github issues and questions posted on stackoverflow but unable to pinpoint this issue. My pycurl installation is done successfully and if I run python -c 'import pycurl' && echo "Success". It returns me success but whenever I run celery worker it still gives me the pycurl error.
I was expecting celery to run successfully but in return I get an import error.
If I go to the kombu package which is installed and try to print traceback value then it outputs:
pycurl: libcurl link-time version (7.76.1) is older than compile-time version (7.86.0)
brew info openssl output is as follow:
openssl@3 is keg-only, which means it was not symlinked into /usr/local,
because macOS provides LibreSSL.
If you need to have openssl@3 first in your PATH, run:
echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> /Users/<>/.bash_profile
For compilers to find openssl@3 you may need to set:
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
For pkg-config to find openssl@3 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"
brew info curl output is as follows:
curl is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have curl first in your PATH, run:
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> /Users/<>/.bash_profile
For compilers to find curl you may need to set:
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"
For pkg-config to find curl you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/curl/lib/pkgconfig"
I encountered this issue on a Mac Pro (intel) running Ventura 13.0. Seems like many others have had mixed results fixing the problem given the number of posts on SO and other sites. This worked for me but your mileage may vary.
This approach ensures the pycurl version matches the macOS version of curl. Other approaches try to install curl from homebrew and link against that. The homebrew approach seems to work for python but Django and celery always linked against the built in curl.
The Problem
Note the link time version
libcurl link-time version (7.84.0). Yours may be different.The Solution
Build pycurl against same source as the installed version.
You can find some great conversation on the issue here: https://gist.github.com/vidakDK/de86d751751b355ed3b26d69ecdbdb99