celery -A workers worker --loglevel=INFO -c 2
...
File "/Users/USERNAME/.pyenv/versions/3.8.5/envs/notifications38/lib/python3.8/site-packages/kombu/asynchronous/http/curl.py", line 41, in __init__
raise ImportError('The curl client requires the pycurl library.')
ImportError: The curl client requires the pycurl library.
Derived from the import of pycurl:
❯ python3
Python 3.8.5 (default, Sep 3 2021, 09:13:17)
[Clang 12.0.5 (clang-1205.0.22.9)] on darwin
>>> import pycurl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: pycurl: libcurl link-time version (7.79.1) is older than compile-time version (7.87.0)
- Reinstalling both openssl and curl from brew to be sure we have the latest versions:
brew uninstall openssl
brew uninstall curl
brew install openssl
brew install curl
Check the paths of the libraries so you can properly set LDFLAGS and CPPFLAGS
- Reinstall pycurl
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl х INT Py notifications38 3.8.5
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"
pip install pycurl --config-settings="--build-option=--with-openssl" --config-settings="build-option=--openssl-dir=/usr/local/opt/openssl" --no-binary :all: --no-cache-dir
# For older version of pip <23.1
# pip install --verbose --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" --install-option="--openssl-dir=/usr/local/opt/[email protected]" pycurl
- Check if the error still persists:
python3
import pycurl
- If the error still persists, check with otool what linked curl library has the installed python library:
❯ otool -L /Users/USERNAME/.pyenv/versions/3.8.5/envs/notifications38/lib/python3.8/site-packages/pycurl.cpython-38-darwin.so
/Users/USERNAME/.pyenv/versions/3.8.5/envs/notifications38/lib/python3.8/site-packages/pycurl.cpython-38-darwin.so:
/usr/local/opt/[email protected]/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/opt/[email protected]/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
If the library is the system one, /usr/lib/libcurl.4.dylib
, just swap it to the proper one:
❯ install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib /Users/USERNAME/.pyenv/versions/3.8.5/envs/notifications38/lib/python3.8/site-packages/pycurl.cpython-38-darwin.so
❯ otool -L /Users/USERNAME/.pyenv/versions/3.8.5/envs/notifications38/lib/python3.8/site-packages/pycurl.cpython-38-darwin.so
/Users/USERNAME/.pyenv/versions/3.8.5/envs/notifications38/lib/python3.8/site-packages/pycurl.cpython-38-darwin.so:
/usr/local/opt/[email protected]/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/opt/[email protected]/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/opt/curl/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 9.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)