Skip to content

mac下python3 安装pycurl

最近在一个小工具上需要用到pycrul,但是在安装pycurl之后,出现:

ImportError: pycurl: libcurl link-time ssl backend (openssl) 的错误。

百度之后找打文章:

http://www.nxadmin.com/system/other/1290.html

大致操作如下:

pip3 uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
pip3 install pycurl –compile

但是按照相关的操作之后出现错误:

ERROR: Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/yv/k3cn704s7jq1t7h0m99x9y2w0000gn/T/pip-install-34lcd2wa/pycurl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/yv/k3cn704s7jq1t7h0m99x9y2w0000gn/T/pip-record-srwauv2n/install-record.txt --single-version-externally-managed --compile:
    ERROR: Using curl-config (libcurl 7.54.0)
    Using SSL library: OpenSSL/LibreSSL/BoringSSL
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.7
    creating build/lib.macosx-10.9-x86_64-3.7/curl
    copying python/curl/__init__.py -> build/lib.macosx-10.9-x86_64-3.7/curl
    running build_ext
    building 'pycurl' extension
    creating build/temp.macosx-10.9-x86_64-3.7
    creating build/temp.macosx-10.9-x86_64-3.7/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DPYCURL_VERSION="7.43.0.3" -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c src/docstrings.c -o build/temp.macosx-10.9-x86_64-3.7/src/docstrings.o
    In file included from src/docstrings.c:4:
    src/pycurl.h:164:13: fatal error: 'openssl/ssl.h' file not found
    #   include <openssl/ssl.h>
                ^~~~~~~~~~~~~~~
    1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/yv/k3cn704s7jq1t7h0m99x9y2w0000gn/T/pip-install-34lcd2wa/pycurl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/yv/k3cn704s7jq1t7h0m99x9y2w0000gn/T/pip-record-srwauv2n/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/yv/k3cn704s7jq1t7h0m99x9y2w0000gn/T/pip-install-34lcd2wa/pycurl/

其中重点部分
fatal error: ‘openssl/ssl.h’ file not found

最终解决办法:

PYCURL_SSL_LIBRARY=openssl LDFLAGS=”-L/usr/local/opt/openssl/lib” CPPFLAGS=”-I/usr/local/opt/openssl/include” pip3 install –no-cache-dir pycur

发表评论

电子邮件地址不会被公开。 必填项已用*标注