Error when installing libcurl with nss backend (Python 3.6 64bit A. Linux)

0

I have an instance running Python3.6 in Amazon Linux where I need to install pycurl with NSS ssl backend. It needs to be with NSS because it's a Django app that runs backend processes with celery and SQS.

When I specified, in requirements.txt,:

pycurl==7.43.0 --global-option="--with-nss"

I got some errors, so I ended up installing it through an .ebextensions file, like suggested in a stackoverflow post:

container_commands:
  09_pycurl_reinstall:
    # the upgrade option is because it will run after PIP installs the requirements.txt file.
    # and it needs to be done with the virtual-env activated
    command: 'source /opt/python/run/venv/bin/activate && PYCURL_SSL_LIBRARY=nss pip3 install pycurl --global-option="--with-nss" --upgrade --no-cache-dir --compile --ignore-installed'

This gave me the error:

__main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory

I found in a stackoverflow thread (https://stackoverflow.com/questions/23937933/could-not-run-curl-config-errno-2-no-such-file-or-directory-when-installing) that the problem is that I needed to first install libcurl. As I need it to run with NSS backend, I wanted to do:

sudo apt libcurl4-nss-dev

but I can't do it because the instance is running in Amazon Linux. So, as suggested in an answer in the same thread, I instead did:

yum install libcurl-devel

The problem with this, if I'm understanding it correctly, is that it installs libcurl with OpenSSL instead of NSS (I have already set the environment variable PYCURL_SSL_LIBRARY=nss, but it seems to do nothing), so I get the following error:

ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (nss)

I know it has to be possible to do it, because I myself did it some months ago (after struggling for 3 whole weeks).

My questions are:

  1. Am I right in my diagnose? Is the problem that libcurl is being installed with OpenSSL backend and pycurl is being installed with NSS backend when they should both be NSS?
  2. If so, how can I install libcurl with NSS backend? This seems straightforward with apt get (install libcurl4-nss-dev), but I don't know how to do it in yum, where the only available packages are:
libcurl-devel.x86_64 : Files needed for building applications with libcurl
libcurl.i686 : A library for getting files from web servers
libcurl.x86_64 : A library for getting files from web servers

so, there's no package that says "nss". I don't remember how I solved it the last time, maybe I didn't use yum (I'm pretty new to all of this). I've been trying different things for the past 2 weeks with no look, and it's driving me crazy. Any help would be appreciated.

Thank you very much.

TECHNICAL INFO:
Environment running on Python3.6 64bit Amazon Linux/2.8.3. It is a Django application using celery to execute tasks with an SQS queue. Celery tasks are correctly being sent to the SQS queue, but the celery-worker doesn't work because of the problem I just described, so the messages stay in the queue (celery-beat seems to be working fine).

Edited by: jaumeF on May 8, 2019 4:02 AM
grammar

jaumeF
asked 5 years ago781 views
3 Answers
0

Did you manage to solve this problem? We have practically the same setup (Django, SQS, Beanstalk, Celery) The error I always get on AWS is:
ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually.

Tried all sorts of solutions on stackoverflow but no success so far :(
Currently I try to install pycurl manually through SSH on EC2 instance with different options like
sudo /opt/python/run/venv/bin/pip3 install pycurl --global-option="--with-nss" --no-cache-dir --compile
but I always get the error stated above

answered 5 years ago
0
answered 5 years ago
0

Hi greg,

thank you for your time and sorry for the late reply.

I added your python config code inside .ebextensions and it is not working.

I'm assuming you do NOT include pycurl in requirements.txt, so I'm not including it. When trying to deploy, I get this error:

[Instance: i-0f1b890f9b54a47aa] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ne which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually. ---------------------------------------- ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-2sam3zww/pycurl/. command 04_pycurl_reinstall in .ebextensions/01_pycurl.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.

Which refers to this chunk in eb-activity.log:

File "/tmp/pip-install-qpd0hgmf/pycurl/setup.py", line 316, in configure_unix
  specify the SSL backend manually.''')
  __main__.ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually.

So it looks like I need to specify pycurl backend somewhere. If I specify "--with-nss" I'm back to the beginning: deployment succeeds but celery workers are not functioning because (celery-worker.log):

raise ImportError('The curl client requires the pycurl library.')
ImportError: The curl client requires the pycurl library.

Ssh connecting and doing python3.6 -c 'import pycurl' gives more info on the error:

ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time s                                           sl backend (nss)

One question: with your solution, you ended up with OpenSSL instead of NSS, right? Are your workers able to connect to SQS? I'm not sure, but I remember I tried it some time ago and connection always shut down after a few hours and workers failed.

Or are you using nss? How?

Thanks and sorry, I'm really lost and desperate (I don't comment on the stackoverflow thread cause I don't have enough reputation).

jaumeF
answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions