title: ImportError on `import pycurl` (Python 3.10, macOS)
body: <p>Working from <a href="https://gist.github.com/vidakDK/de86d751751b355ed3b26d69ecdbdb99" rel="nofollow noreferrer">https://gist.github.com/vidakDK/de86d751751b355ed3b26d69ecdbdb99</a> I execute these commands:</p>
  <pre class="lang-sh prettyprint-override"><code>brew install openssl
  brew install curl  # this is the latest version with openssl
  
  . .venv/bin/activate
  
  export PATH=&quot;/usr/local/opt/openssl@1.1/bin:$PATH&quot;
  export PATH=&quot;/usr/local/opt/curl/bin:$PATH&quot;
  
  export LDFLAGS=&quot;-L/usr/local/Cellar/curl/7.80.0/lib&quot;
  export CPPFLAGS=&quot;-I/usr/local/Cellar/curl/7.80.0/include&quot;
  
  pip install \
      --no-cache-dir \
      --compile \
      --ignore-installed \
      --install-option=&quot;--with-openssl&quot; \
      --install-option=&quot;--openssl-dir=/usr/local/opt/openssl@1.1&quot; \
          pycurl
  </code></pre>
  <p>It appears to complete. However testing <code>import pycurl</code> in Python from the CLI fails:</p>
  <pre><code>&gt; python
  Python 3.10.0 (default, Oct 23 2021, 18:32:23) [Clang 13.0.0 (clang-1300.0.29.3)] on darwin
  Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  &gt;&gt;&gt; import pycurl
  Traceback (most recent call last):
    File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  ImportError: pycurl: libcurl link-time version (7.64.1) is older than compile-time version (7.80.0)
  </code></pre>
  <p>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.</p>
  <p>I can see the 2 versions in question on my system:</p>
  <pre><code>(.venv)
   pi@pPro18-4 ~/curlfail
  &gt; which curl
  /usr/local/opt/curl/bin/curl
  
  (.venv)
   pi@pPro18-4 ~/curlfail
  &gt; /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
  &gt; 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
  &gt; /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
  &gt; /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
  </code></pre>
  <p>What am I missing?</p>
  <p>PS <code>hash -r</code> has been suggested also to clear terminal memory</p>
  <hr />
  <p>UPDATE:</p>
  <p>A new post has been added to the referenced gist.<br />
  The author states that a coworker got this working. Their <code>gcc --version</code> reports &quot;InstalledDir: /Library/Developer/CommandLineTools/usr/bin&quot; whereas his (pycurl fail) reports &quot;InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin&quot;</p>
  <p>So I list all my gcc executables:</p>
  <pre><code>&gt; find / -name gcc -type f 2&gt;/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
  </code></pre>
  <p>I now run <code>/path/to/gcc --version</code> on each. And EVERY ONE has &quot;InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin&quot;</p>
  <p>Specifically:</p>
  <pre><code>&gt; /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
  </code></pre>
  <p>I have filed an issue: <a href="https://github.com/pycurl/pycurl/issues/718" rel="nofollow noreferrer">https://github.com/pycurl/pycurl/issues/718</a></p>
  <p>Linked: <a href="https://stackoverflow.com/questions/70119147/how-to-install-gcc-on-macos-such-that-gcc-version-reports-installeddir-li">How to install gcc on macOS such that `gcc --version` reports &quot;InstalledDir: /Library/Developer/CommandLineTools/usr/bin&quot;</a></p>
  <p>^ NOTE: answer has been provided there: <code>sudo xcode-select -switch /Library/Developer/CommandLineTools</code></p>