如何在ActivePython-2.6中安装pyCurl?

4 投票
4 回答
7774 浏览
提问于 2025-04-15 12:29

我之前用过pyCurl,并且它在我系统默认的Python安装上运行得很好。不过,我现在有一个项目需要Python更便携,所以我在使用ActivePython-2.6。

到目前为止,我安装其他模块没有遇到任何问题,但在安装pyCurl时却出现了错误。错误信息是:

Searching for pycurl
Reading http://pypi.python.org/simple/pycurl/
Reading http://pycurl.sourceforge.net/
Reading http://pycurl.sourceforge.net/download/
Best match: pycurl 7.19.0
Downloading http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar.gz
Processing pycurl-7.19.0.tar.gz
Running pycurl-7.19.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-tfVLW6/pycurl-7.19.0/egg-dist-tmp-p1WjAy
sh: curl-config: not found
Traceback (most recent call last):
  File "/opt/ActivePython-2.6/bin/easy_install", line 8, in <module>
    load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')()
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 1671, in main
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 1659, in with_ei_usage
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 1675, in <lambda>
  File "/opt/ActivePython-2.6/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/opt/ActivePython-2.6/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/opt/ActivePython-2.6/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 211, in run
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 446, in easy_install
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 476, in install_item
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 655, in install_eggs
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 930, in build_and_install
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/command/easy_install.py", line 919, in run_setup
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py", line 27, in run_setup
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py", line 63, in run
  File "/opt/ActivePython-2.6/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg/setuptools/sandbox.py", line 29, in <lambda>
  File "setup.py", line 90, in <module>
Exception: `curl-config' not found -- please install the libcurl development files

我的系统上确实安装了libcurl,但ActivePython似乎找不到它。

任何建议都很有帮助!

4 个回答

1
$ apt-cache depends python-pycurl
python-pycurl
  Depends: libc6
  Depends: libcurl3-gnutls
  Depends: libgnutls26
  Depends: libidn11
  Depends: libkrb53
  Depends: libldap-2.4-2
  Depends: zlib1g
  Depends: python
  Depends: python
  Depends: python-central
[...]

首先,通过运行 sudo aptitude install libcurl3-gnutls(或者你系统的包管理工具)来安装所需的依赖项,然后再执行 easy_install pycurl

1

我找不到可以添加到路径中的curl-config,这也没什么奇怪的,因为它似乎不是一个可以直接调用的模块。

最后找到的解决办法有点像是小技巧,但确实有效。

因为我在本地的python2.6安装中已经成功使用了pyCurl,所以我只是把本地安装中的curl和pycurl的相关文件复制到了ActivePython的安装中。

5

安装pycurl需要以下依赖:

apt-cache depends python-pycurl
python-pycurl
 Depends: libc6
Depends: libcurl3-gnutls
Depends: libgcrypt11
Depends: python2.7
Depends: python
Depends: python
Suggests: libcurl4-gnutls-dev
Suggests: python-pycurl-dbg
Conflicts: <python2.3-pycurl>
Conflicts: <python2.3-pycurl:i386>
Conflicts: <python2.4-pycurl>
Conflicts: <python2.4-pycurl:i386>
Replaces: <python2.3-pycurl>
Replaces: <python2.3-pycurl:i386>
Replaces: <python2.4-pycurl>
Replaces: <python2.4-pycurl:i386>
Conflicts: python-pycurl:i386

运行这个命令

sudo apt-get install libcurl4-gnutls-dev librtmp-dev

然后你可以用下面的方式安装pycurl

pip install pycurl

或者

easy_install pycurl

撰写回答