pip install pycurl 在 Ubuntu 18.04 上失败

pip install pycurl 在 Ubuntu 18.04 上失败

我想在 Ubuntu 18.04 上安装pycurlPython pip3.7。从“deadsnakes”安装的 Python3.7。

apt-cache depends python-pycurl我得到:

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

然后我安装了以下内容:

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

然后我尝试:

pip install pycurl

我有:

Collecting pycurl
  Using cached https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz
Building wheels for collected packages: pycurl
  Building wheel for pycurl (setup.py) ... error
  ERROR: Complete output from command /usr/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-de7mbdj3/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/pip-wheel-85pj90gy --python-tag cp37:
  ERROR: Using curl-config (libcurl 7.58.0)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/curl
  copying python/curl/__init__.py -> build/lib.linux-x86_64-3.7/curl
  running build_ext
  building 'pycurl' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/docstrings.c -o build/temp.linux-x86_64-3.7/src/docstrings.o
  In file included from src/docstrings.c:4:0:
  src/pycurl.h:4:10: fatal error: Python.h: No such file or directory
   #include <Python.h>
            ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pycurl
  Running setup.py clean for pycurl
Failed to build pycurl
Installing collected packages: pycurl
  Running setup.py install for pycurl ... error
    ERROR: Complete output from command /usr/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-de7mbdj3/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 /tmp/pip-record-0n2ynluk/install-record.txt --single-version-externally-managed --compile:
    ERROR: Using curl-config (libcurl 7.58.0)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/curl
    copying python/curl/__init__.py -> build/lib.linux-x86_64-3.7/curl
    running build_ext
    building 'pycurl' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/docstrings.c -o build/temp.linux-x86_64-3.7/src/docstrings.o
    In file included from src/docstrings.c:4:0:
    src/pycurl.h:4:10: fatal error: Python.h: No such file or directory
     #include <Python.h>
              ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/usr/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-de7mbdj3/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 /tmp/pip-record-0n2ynluk/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-de7mbdj3/pycurl/

安装后libpython3.7-dev

Collecting pycurl
  Using cached https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz
Building wheels for collected packages: pycurl
  Building wheel for pycurl (setup.py) ... error
  ERROR: Complete output from command /usr/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ww9s3047/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/pip-wheel-t5aeuzkr --python-tag cp37:
  ERROR: Using curl-config (libcurl 7.58.0)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.7
  creating build/lib.linux-x86_64-3.7/curl
  copying python/curl/__init__.py -> build/lib.linux-x86_64-3.7/curl
  running build_ext
  building 'pycurl' extension
  creating build/temp.linux-x86_64-3.7
  creating build/temp.linux-x86_64-3.7/src
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/docstrings.c -o build/temp.linux-x86_64-3.7/src/docstrings.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easy.c -o build/temp.linux-x86_64-3.7/src/easy.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easycb.c -o build/temp.linux-x86_64-3.7/src/easycb.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easyinfo.c -o build/temp.linux-x86_64-3.7/src/easyinfo.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easyopt.c -o build/temp.linux-x86_64-3.7/src/easyopt.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easyperform.c -o build/temp.linux-x86_64-3.7/src/easyperform.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/module.c -o build/temp.linux-x86_64-3.7/src/module.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/multi.c -o build/temp.linux-x86_64-3.7/src/multi.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/oscompat.c -o build/temp.linux-x86_64-3.7/src/oscompat.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/pythoncompat.c -o build/temp.linux-x86_64-3.7/src/pythoncompat.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/share.c -o build/temp.linux-x86_64-3.7/src/share.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/stringcompat.c -o build/temp.linux-x86_64-3.7/src/stringcompat.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/threadsupport.c -o build/temp.linux-x86_64-3.7/src/threadsupport.o
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/util.c -o build/temp.linux-x86_64-3.7/src/util.o
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/src/docstrings.o build/temp.linux-x86_64-3.7/src/easy.o build/temp.linux-x86_64-3.7/src/easycb.o build/temp.linux-x86_64-3.7/src/easyinfo.o build/temp.linux-x86_64-3.7/src/easyopt.o build/temp.linux-x86_64-3.7/src/easyperform.o build/temp.linux-x86_64-3.7/src/module.o build/temp.linux-x86_64-3.7/src/multi.o build/temp.linux-x86_64-3.7/src/oscompat.o build/temp.linux-x86_64-3.7/src/pythoncompat.o build/temp.linux-x86_64-3.7/src/share.o build/temp.linux-x86_64-3.7/src/stringcompat.o build/temp.linux-x86_64-3.7/src/threadsupport.o build/temp.linux-x86_64-3.7/src/util.o -lssl3 -lcurl -o build/lib.linux-x86_64-3.7/pycurl.cpython-37m-x86_64-linux-gnu.so
  /usr/bin/ld: cannot find -lssl3
  collect2: error: ld returned 1 exit status
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pycurl
  Running setup.py clean for pycurl
Failed to build pycurl
Installing collected packages: pycurl
  Running setup.py install for pycurl ... error
    ERROR: Complete output from command /usr/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ww9s3047/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 /tmp/pip-record-obgqqm_m/install-record.txt --single-version-externally-managed --compile:
    ERROR: Using curl-config (libcurl 7.58.0)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/curl
    copying python/curl/__init__.py -> build/lib.linux-x86_64-3.7/curl
    running build_ext
    building 'pycurl' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/docstrings.c -o build/temp.linux-x86_64-3.7/src/docstrings.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easy.c -o build/temp.linux-x86_64-3.7/src/easy.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easycb.c -o build/temp.linux-x86_64-3.7/src/easycb.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easyinfo.c -o build/temp.linux-x86_64-3.7/src/easyinfo.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easyopt.c -o build/temp.linux-x86_64-3.7/src/easyopt.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/easyperform.c -o build/temp.linux-x86_64-3.7/src/easyperform.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/module.c -o build/temp.linux-x86_64-3.7/src/module.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/multi.c -o build/temp.linux-x86_64-3.7/src/multi.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/oscompat.c -o build/temp.linux-x86_64-3.7/src/oscompat.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/pythoncompat.c -o build/temp.linux-x86_64-3.7/src/pythoncompat.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/share.c -o build/temp.linux-x86_64-3.7/src/share.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/stringcompat.c -o build/temp.linux-x86_64-3.7/src/stringcompat.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/threadsupport.c -o build/temp.linux-x86_64-3.7/src/threadsupport.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_NSS=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/util.c -o build/temp.linux-x86_64-3.7/src/util.o
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fdebug-prefix-map=/build/python3.7-0Cmdei/python3.7-3.7.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.7/src/docstrings.o build/temp.linux-x86_64-3.7/src/easy.o build/temp.linux-x86_64-3.7/src/easycb.o build/temp.linux-x86_64-3.7/src/easyinfo.o build/temp.linux-x86_64-3.7/src/easyopt.o build/temp.linux-x86_64-3.7/src/easyperform.o build/temp.linux-x86_64-3.7/src/module.o build/temp.linux-x86_64-3.7/src/multi.o build/temp.linux-x86_64-3.7/src/oscompat.o build/temp.linux-x86_64-3.7/src/pythoncompat.o build/temp.linux-x86_64-3.7/src/share.o build/temp.linux-x86_64-3.7/src/stringcompat.o build/temp.linux-x86_64-3.7/src/threadsupport.o build/temp.linux-x86_64-3.7/src/util.o -lssl3 -lcurl -o build/lib.linux-x86_64-3.7/pycurl.cpython-37m-x86_64-linux-gnu.so
    /usr/bin/ld: cannot find -lssl3
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/usr/bin/python3.7 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ww9s3047/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 /tmp/pip-record-obgqqm_m/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ww9s3047/pycurl/

答案1

经过几次迭代后发现,编译时缺少一些开发包pycurl

apt-get install libpython3.7-dev libnss3 libnss3-dev

的基本提示libpython3.7-dev如下。

src/pycurl.h:4:10: fatal error: Python.h: No such file or directory 

这表示Python.h缺失或无法找到。在这种情况下,找到相关包有点困难,因为很多包都提供此文件。您可以使用

apt-file search Python.h

搜索提供此文件的软件包。由于您尝试使用系统提供的 Python 3.7 软件包进行编译,因此它还应命名为libpython包括版本在内的名称。


第二个提示如下。

/usr/bin/ld: cannot find -lssl3

这说明链接器无法找到libssl3.so要将新编译的pycurl对象链接到的库。您还可以使用apt-file search来查找提供此库的包。不确定-dev这里是否也需要这个包,但如果您也安装它,应该没关系。

答案2

这是一个老话题,以前的解决方案对我来说不起作用。我不得不更改 openssl 的路径,我在这里评论它,我相信这可能会节省一些人的时间。我正在使用的机器

MacOS: Apple M1 Pro (Ventura v13.4)

pip uninstall pycurl
PYCURL_SSL_LIBRARY=openssl LDFLAGS="-L/opt/homebrew/opt/openssl/lib" CPPFLAGS="-I/opt/homebrew/opt/openssl/include" pip install --no-cache-dir pycurl

相关内容