jau*_*ume 5 python libcurl amazon-ec2 pycurl amazon-web-services
我在 AWS 中有一个运行 Python3.6 (Amazon Linux/2.8.3) 的 ec2 实例,我需要在其中安装 pycurl 和 NSS ssl backend。
pycurl==7.43.0 --global-option="--with-nss"首先,我通过添加到我的文件中进行尝试requirement.txt,但出现错误安装错误。因此,我最终通过添加一个.config文件.ebextensions(在部署期间运行)来完成此操作:
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'
Run Code Online (Sandbox Code Playgroud)
Pycurl 似乎已正确安装,但 celery 工作程序未运行。芹菜工人日志显示:
__main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)
如果我 ssh 连接到实例并运行,python 3.6 -c 'import pycurl'我会收到更详细的错误:
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (nss)
Run Code Online (Sandbox Code Playgroud)
所以我想我的问题是我之前用openSSL而不是NSS安装了libcurl,因此libcurl和pycurl之间不匹配。
根据另一个 stackoverflow 问题,为了将 libcurl 与 NSS 后端一起安装,我应该安装它:
sudo apt libcurl4-nss-dev
Run Code Online (Sandbox Code Playgroud)
但由于服务器运行的是 Amazon Linux,我无法使用该apt命令。所以我改为:
yum install libcurl-devel
Run Code Online (Sandbox Code Playgroud)
我猜这就是问题所在:当我需要 NSS 支持时,它会安装带有 OpenSSL 支持的 libcurl。
如何在 Amazon Linux 中使用 NSS 安装 libcurl?(我需要 NSS,因为我正在使用 SQS 作为代理运行带有 celery 的 Django 应用程序,而 SQS 需要 NSS)。
非常感谢!
我刚刚遇到了同样的问题并设法解决了它:)
libcurl:curl-config --configure
Run Code Online (Sandbox Code Playgroud)
所有涉及路径的选项都可以忽略,但如果您想要与 system 相同的功能,则必须保留其他选项libcurl。当然--with-ssl会替换成--without-ssl --with-nss.
1.1 安装前提条件:
sudo yum install libssh2-devel nss-devel
Run Code Online (Sandbox Code Playgroud)
(当然,您应该将 then 添加到ebextensions 的packages>部分)yum
libcurl(我选择 7.61.1 以匹配 Amazon Linux 2018.03 使用的版本):wget https://curl.haxx.se/download/curl-7.61.1.tar.gz
tar xf curl-7.61.1.tar.gz
cd curl-7.61.1
./configure '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-amazon-linux-gnu' '--program-prefix=' '--cache-file=../config.cache' '--disable-static' '--enable-symbol-hiding' '--enable-ipv6' '--enable-threaded-resolver' '--with-gssapi' '--with-nghttp2' '--without-ssl' '--with-nss' '--with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt' '--enable-ldap' '--enable-ldaps' '--enable-manual' '--with-libidn2' '--with-libpsl' '--with-libssh2' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'target_alias=x86_64-amazon-linux-gnu' 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
make
sudo make install
Run Code Online (Sandbox Code Playgroud)
(当然,这应该通过filesebextensions 部分作为 Shell 脚本正确部署)。
现在您应该看到libcurl.so.4创建于/usr/local/lib.
pycurl使用您的自定义进行编译libcurl:LD_LIBRARY_PATH=/usr/local/lib
PYCURL_CURL_CONFIG=/usr/local/bin/curl-config
PYCURL_SSL_LIBRARY=nss
Run Code Online (Sandbox Code Playgroud)
pip install您可以检查pycurl右侧的链接libcurl:
ldd /opt/python/run/venv/local/lib64/python3.6/site-packages/pycurl.cpython-36m-x86_64-linux-gnu.so
Run Code Online (Sandbox Code Playgroud)
应该告诉你libcurl.so.4 => /usr/local/lib64/libcurl.so.4
当然python 3.6 -c 'import pycurl'应该有效。
就是这样!您应该能够使用 SQS 运行 Celery。
| 归档时间: |
|
| 查看次数: |
3485 次 |
| 最近记录: |