安装pycurl时出现“无法运行curl-config:[Errno 2]没有这样的文件或目录”

问题:安装pycurl时出现“无法运行curl-config:[Errno 2]没有这样的文件或目录”

我正在尝试通过以下方式安装pycurl:

sudo pip install pycurl

它下载得很好,但是当它运行setup.py时,我得到以下回溯:

Downloading/unpacking pycurl
  Running setup.py egg_info for package pycurl
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-root/pycurl/setup.py", line 563, in <module>
        ext = get_extension()
      File "/tmp/pip-build-root/pycurl/setup.py", line 368, in get_extension
        ext_config = ExtensionConfiguration()
      File "/tmp/pip-build-root/pycurl/setup.py", line 65, in __init__
        self.configure()
      File "/tmp/pip-build-root/pycurl/setup.py", line 100, in configure_unix
        raise ConfigurationError(msg)
    __main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip-build-root/pycurl/setup.py", line 563, in <module>

    ext = get_extension()

  File "/tmp/pip-build-root/pycurl/setup.py", line 368, in get_extension

    ext_config = ExtensionConfiguration()

  File "/tmp/pip-build-root/pycurl/setup.py", line 65, in __init__

    self.configure()

  File "/tmp/pip-build-root/pycurl/setup.py", line 100, in configure_unix

    raise ConfigurationError(msg)

__main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory

任何想法为什么会这样以及如何解决它

I’m trying to install pycurl via:

sudo pip install pycurl

It downloaded fine, but when when it runs setup.py I get the following traceback:

Downloading/unpacking pycurl
  Running setup.py egg_info for package pycurl
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-root/pycurl/setup.py", line 563, in <module>
        ext = get_extension()
      File "/tmp/pip-build-root/pycurl/setup.py", line 368, in get_extension
        ext_config = ExtensionConfiguration()
      File "/tmp/pip-build-root/pycurl/setup.py", line 65, in __init__
        self.configure()
      File "/tmp/pip-build-root/pycurl/setup.py", line 100, in configure_unix
        raise ConfigurationError(msg)
    __main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/tmp/pip-build-root/pycurl/setup.py", line 563, in <module>

    ext = get_extension()

  File "/tmp/pip-build-root/pycurl/setup.py", line 368, in get_extension

    ext_config = ExtensionConfiguration()

  File "/tmp/pip-build-root/pycurl/setup.py", line 65, in __init__

    self.configure()

  File "/tmp/pip-build-root/pycurl/setup.py", line 100, in configure_unix

    raise ConfigurationError(msg)

__main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory

Any idea why this is happening and how to get around it


回答 0

在Debian上,我需要以下软件包来解决此问题

sudo apt install libcurl4-openssl-dev libssl-dev

On Debian I needed the following packages to fix this

sudo apt install libcurl4-openssl-dev libssl-dev

回答 1

yum包管理器类似

yum install libcurl-devel

如果您使用dnf,请使用

dnf install libcurl-devel

Similarly with yum package manager

yum install libcurl-devel

If you use dnf, use

dnf install libcurl-devel

回答 2

就我而言,这解决了问题:

sudo apt-get install libssl-dev libcurl4-openssl-dev python-dev

这里解释

in my case this fixed the problem:

sudo apt-get install libssl-dev libcurl4-openssl-dev python-dev

as explained here


回答 3

在Alpine linux中,您应该执行以下操作:

apk add curl-dev python3-dev libressl-dev

In Alpine linux you should do:

apk add curl-dev python3-dev libressl-dev

回答 4

我在尝试使Shinken 2.0.3在Ubuntu上启动时遇到了相同的问题。最终,我进行了完全卸载,然后使用重新安装了Shinken pip -v。在清理过程中,它提到:

Warning: missing python-pycurl lib, you MUST install it before launch the shinken daemons

安装了apt-get,所有经纪人都按预期启动了:-)

I encountered the same problem whilst trying to get Shinken 2.0.3 to fire up on Ubuntu. Eventually I did a full uninstall then reinstalled Shinken with pip -v. As it cleaned up, it mentioned:

Warning: missing python-pycurl lib, you MUST install it before launch the shinken daemons

Installed that with apt-get, and all the brokers fired up as expected :-)


回答 5

那解决了我在Ubuntu 14.04上的问题:

apt-get安装libcurl4-gnutls-dev

That solved my problem on Ubuntu 14.04:

apt-get install libcurl4-gnutls-dev


回答 6

在OpenSUSE上:

zypper in libcurl-devel 

On OpenSUSE:

zypper in libcurl-devel 

回答 7

就我而言,我一直收到相同的错误消息。我使用软呢帽。我通过以下方法解决了它:

sudo dnf install pycurl

这安装了我需要它运行的一切。

In my case i kept getting the same error message. I use fedora. I solved it by doing:

sudo dnf install pycurl

This installed eveything that I needed for it to work.


回答 8

我在Mac上遇到了这个问题,这与该openssl软件包是所需的旧版本有关pycurlpycurl根据我的理解,可以使用其他SSL库而不是openssl。验证您所使用的SSL库并进行更新,因为它很可能解决了该问题。

我通过以下方式解决了这个问题:

  • 跑步 brew upgrade
  • pycurl-x.y.z.tar.gzhttp://pycurl.io/下载了最新的
  • 提取上面的包并在其中更改目录
  • python setup.py --with-openssl install如OpenSSL是我已经安装了库。如果你是SSL库或者是gnutls还是nss那么将不得不使用--with-gnutls--with-nss相应。您将可以在其github存储库中找到更多安装信息

I had this issue on Mac and it was related to the openssl package being an older version of what it was required by pycurl. pycurl can use other ssl libraries rather than openssl as per my understanding of it. Verify which ssl library you’re using and update as it is very likely to fix the issue.

I fixed this by:

  • running brew upgrade
  • downloaded the latest pycurl-x.y.z.tar.gz from http://pycurl.io/
  • extracted the package above and change directory into it
  • ran python setup.py --with-openssl install as openssl is the library I have installed. If you’re ssl library is either gnutls or nss then will have to use --with-gnutls or --with-nss accordingly. You’ll be able to find more installation info in their github repository.

回答 9

除了eldos的答案外,我gcc在CentOS 7中还需要:

yum install libcurl-devel gcc

In addition to the answer of eldos I also needed gcc in CentOS 7:

yum install libcurl-devel gcc

回答 10

请注意,如果您使用的是nodejs,则在编写本文时,它会依赖libssl 1.0。*-因此,安装备用SSL库将破坏您的nodejs安装。

安装不同SSL库的另一种解决方案是此答案中的此处发布:https : //stackoverflow.com/a/59927568/13564342来代替安装libcurl4-gnutls-dev

sudo apt install libcurl4-gnutls-dev

Be advised that if you’re using nodejs there’s (at the time of writing) a dependency on libssl 1.0.* – so installing an alternative SSL library will break your nodejs installation.

An alternative solution to installing a different SSL library is that posted in this answer here: https://stackoverflow.com/a/59927568/13564342 to instead install libcurl4-gnutls-dev

sudo apt install libcurl4-gnutls-dev