在 Mac OS 上为 Python 2.6 安装 pycurl

Installing pycurl for Python 2.6 on Mac OS

我有一个 Mac OS (El Capitan 10.11.3),我正在尝试为 Python 2.6.9 安装 pycurl 库。不幸的是,当我尝试时:

 easy_install pycurl

我有:

 Searching for pycurl
 Best match: pycurl 7.19.5.3
 Processing pycurl-7.19.5.3-py2.7-macosx-10.11-intel.egg
 pycurl 7.19.5.3 is already the active version in easy-install.pth

但它适用于 Python 2.7 - 而不是 2.6。

正在检查 bash 中的当前 Python 版本:

 python -V 
 Python 2.6.9

我也试过手动安装(下载.tar并安装)

sudo python setup.py install

输出:

Using curl-config (libcurl 7.43.0)
running install
running build
running build_py
running build_ext
running install_lib
running install_data
creating /System/Library/Frameworks/Python.framework/Versions/2.7/share
error: could not create '/System/Library/Frameworks/Python.framework/Versions/2.7/share': Operation not permitted

同样适用于:

make PYTHON=python2.6

你知道如何为 Python 2.6 安装 pycurl 吗?

尝试

sudo python2.6 -m easy_install pycurl

产出

Installed /Library/Python/2.6/site-packages/pycurl-7.43.0-py2.6-macosx-10.11-intel.egg

我建议您尽可能避免将软件包直接安装到您的系统中。尝试根据您的项目使用它们,使用 virtualenv 等工具。这样既避免了冲突,也可以根据需要选择特定的版本。