pip install pycurl

I ran pip install pycurl and got crazy error

Collecting pycurl
  Downloading pycurl- (195kB)
    100% |████████████████████████████████| 204kB 6.0MB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/tmp/pip-build-msc3b_98/pycurl/setup.py", line 104, in configure_unix
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
        restore_signals, start_new_session)
      File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
        raise child_exception_type(errno_num, err_msg)
    FileNotFoundError: [Errno 2] No such file or directory: 'curl-config'
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-msc3b_98/pycurl/setup.py", line 841, in <module>
        ext = get_extension(sys.argv, split_extension_source=split_extension_source)
      File "/tmp/pip-build-msc3b_98/pycurl/setup.py", line 508, in get_extension
        ext_config = ExtensionConfiguration(argv)
      File "/tmp/pip-build-msc3b_98/pycurl/setup.py", line 72, in __init__
      File "/tmp/pip-build-msc3b_98/pycurl/setup.py", line 108, in configure_unix
        raise ConfigurationError(msg)
    __main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory: 'curl-config'
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-msc3b_98/pycurl/

Apparently pip doesn’t really resolve all of pycurl’s dependencies.

Run apt-cache depends python-pycurl

  Depends: python
  Depends: python
  Depends: <python:any>
  Depends: libc6
  Depends: libcurl3-gnutls
  Suggests: libcurl4-gnutls-dev
  Suggests: python-pycurl-dbg
  Suggests: python-pycurl-doc

See the Suggests. So run

sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install python-pycurl-dbg
sudo apt-get install python-pycurl-doc

Run pip install pycurl, but that still fails due to x86_64-linux-gnu-gcc

Collecting pycurl
  Using cached pycurl-
Building wheels for collected packages: pycurl
  Running setup.py bdist_wheel for pycurl ... error
  Complete output from command /home/elt/.virtualenvs/de/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-bcazyxsx/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpfk6sldmcpip-wheel- --python-tag cp35:
  Using curl-config (libcurl 7.47.0)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.5
  creating build/lib.linux-x86_64-3.5/curl
  copying python/curl/__init__.py -> build/lib.linux-x86_64-3.5/curl
  running build_ext
  building 'pycurl' extension
  creating build/temp.linux-x86_64-3.5
  creating build/temp.linux-x86_64-3.5/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="" -DHAVE_CURL_GNUTLS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.5m -I/home/elt/.virtualenvs/de/include/python3.5m -c src/docstrings.c -o build/temp.linux-x86_64-3.5/src/docstrings.o
  In file included from src/docstrings.c:4:0:
  src/pycurl.h:168:30: fatal error: gnutls/gnutls.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

To save you time, do

# upgrade pip if necessary
pip install --upgrade pip

# remove current pycurl
pip uninstall pycurl


# recompile and install pycurl
pip install --compile pycurl

Ref: http://pycurl.io/docs/latest/install.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s