ImportError on `import pycurl` (Python 3.10, macOS)

Viewed 369

Working from https://gist.github.com/vidakDK/de86d751751b355ed3b26d69ecdbdb99 I execute these commands:

brew install openssl
brew install curl  # this is the latest version with openssl

. .venv/bin/activate

export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export PATH="/usr/local/opt/curl/bin:$PATH"

export LDFLAGS="-L/usr/local/Cellar/curl/7.80.0/lib"
export CPPFLAGS="-I/usr/local/Cellar/curl/7.80.0/include"

pip install \
    --no-cache-dir \
    --compile \
    --ignore-installed \
    --install-option="--with-openssl" \
    --install-option="--openssl-dir=/usr/local/opt/openssl@1.1" \
        pycurl

It appears to complete. However testing import pycurl in Python from the CLI fails:

> python
Python 3.10.0 (default, Oct 23 2021, 18:32:23) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycurl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: pycurl: libcurl link-time version (7.64.1) is older than compile-time version (7.80.0)

Several other engineers have reported the same issue in the comment-thread of that gist within the last month so it may be due to some recent change somewhere.

I can see the 2 versions in question on my system:

(.venv)
 pi@pPro18-4 ~/curlfail
> which curl
/usr/local/opt/curl/bin/curl

(.venv)
 pi@pPro18-4 ~/curlfail
> /usr/local/opt/curl/bin/curl --version
curl 7.80.0 (x86_64-apple-darwin20.6.0) libcurl/7.80.0 (SecureTransport) OpenSSL/1.1.1l zlib/1.2.11 brotli/1.0.9 zstd/1.5.0 libidn2/2.3.2 libssh2/1.10.0 nghttp2/1.46.0 librtmp/2.3 OpenLDAP/2.5.8
Release-Date: 2021-11-10
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets zstd

(.venv)
 pi@pPro18-4 ~/curlfail
> brew list curl
/usr/local/Cellar/curl/7.80.0/bin/curl
/usr/local/Cellar/curl/7.80.0/bin/curl-config
/usr/local/Cellar/curl/7.80.0/include/curl/ (10 files)
/usr/local/Cellar/curl/7.80.0/lib/libcurl.4.dylib
/usr/local/Cellar/curl/7.80.0/lib/pkgconfig/libcurl.pc
/usr/local/Cellar/curl/7.80.0/lib/ (2 other files)
/usr/local/Cellar/curl/7.80.0/libexec/mk-ca-bundle.pl
/usr/local/Cellar/curl/7.80.0/share/aclocal/libcurl.m4
/usr/local/Cellar/curl/7.80.0/share/fish/vendor_completions.d/curl.fish
/usr/local/Cellar/curl/7.80.0/share/man/ (466 files)
/usr/local/Cellar/curl/7.80.0/share/zsh/site-functions/_curl

(.venv)
 pi@pPro18-4 ~/curlfail
> /usr/local/Cellar/curl/7.80.0/bin/curl --version
curl 7.80.0 (x86_64-apple-darwin20.6.0) libcurl/7.80.0 (SecureTransport) OpenSSL/1.1.1l zlib/1.2.11 brotli/1.0.9 zstd/1.5.0 libidn2/2.3.2 libssh2/1.10.0 nghttp2/1.46.0 librtmp/2.3 OpenLDAP/2.5.8
Release-Date: 2021-11-10
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets zstd

(.venv)
 pi@pPro18-4 ~/curlfail
> /usr/bin/curl --version
curl 7.64.1 (x86_64-apple-darwin20.0) libcurl/7.64.1 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.41.0
Release-Date: 2019-03-27
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM NTLM_WB SPNEGO SSL UnixSockets

What am I missing?

PS hash -r has been suggested also to clear terminal memory


UPDATE:

A new post has been added to the referenced gist.
The author states that a coworker got this working. Their gcc --version reports "InstalledDir: /Library/Developer/CommandLineTools/usr/bin" whereas his (pycurl fail) reports "InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"

So I list all my gcc executables:

> find / -name gcc -type f 2>/dev/null
/usr/bin/gcc
/usr/share/file/magic/gcc
/Library/Developer/CommandLineTools/usr/bin/gcc
/System/Volumes/Update/mnt1/usr/bin/gcc
/System/Volumes/Update/mnt1/usr/share/file/magic/gcc
/System/Volumes/Data/usr/share/file/magic/gcc
/System/Volumes/Data/Library/Developer/CommandLineTools/usr/bin/gcc
/System/Volumes/Data/Applications/Xcode10.3.app/Contents/Developer/usr/bin/gcc
/System/Volumes/Data/Applications/Xcode.app/Contents/Developer/usr/bin/gcc
/Applications/Xcode10.3.app/Contents/Developer/usr/bin/gcc
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc

I now run /path/to/gcc --version on each. And EVERY ONE has "InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"

Specifically:

> /Library/Developer/CommandLineTools/usr/bin/gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple clang version 13.0.0 (clang-1300.0.29.3)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

I have filed an issue: https://github.com/pycurl/pycurl/issues/718

Linked: How to install gcc on macOS such that `gcc --version` reports "InstalledDir: /Library/Developer/CommandLineTools/usr/bin"

^ NOTE: answer has been provided there: sudo xcode-select -switch /Library/Developer/CommandLineTools

0 Answers
Related