Mac OS 10.8上的pycurl错误

时间:2014-03-15 12:35:03

标签: python macos

我已经使用pip

安装了pycurl
oczml:~ acid$ sudo pip install pycurl
Password:
Downloading/unpacking pycurl
  Downloading pycurl-7.19.3.1.tar.gz (116kB): 116kB downloaded
  Running setup.py egg_info for package pycurl
    Using curl-config (libcurl 7.24.0)

Installing collected packages: pycurl
  Running setup.py install for pycurl
    Using curl-config (libcurl 7.24.0)
    building 'pycurl' extension
    clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPYCURL_VERSION="7.19.3.1" -DHAVE_CURL_SSL=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/pycurl.c -o build/temp.macosx-10.8-intel-2.7/src/pycurl.o
    clang: warning: argument unused during compilation: '-mno-fused-madd'
    src/pycurl.c:123:4: warning: "libcurl was compiled with SSL support, but configure could not determine which "    "library was used; thus no SSL crypto locking callbacks will be set, which may "    "cause random crashes on SSL requests" [-W#warnings]
    #  warning \
       ^
    1 warning generated.
    src/pycurl.c:123:4: warning: "libcurl was compiled with SSL support, but configure could not determine which "    "library was used; thus no SSL crypto locking callbacks will be set, which may "    "cause random crashes on SSL requests" [-W#warnings]
    #  warning \
       ^
    src/pycurl.c:1555:26: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                int sockfd = PyInt_AsLong(fileno_result);
                    ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:1630:24: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
            int ret_code = PyInt_AsLong(result);
                ~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:2447:31: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                            val = PyLong_AsLong(PyTuple_GET_ITEM(t, j));
                                ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:3610:22: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
            tv.tv_usec = (long)(timeout*1000000.0);
                       ~ ^~~~~~~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:4513:27: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
        libcurl_version_len = strlen(libcurl_version);
                            ~ ^~~~~~~~~~~~~~~~~~~~~~~
    6 warnings generated.
    clang -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.8-intel-2.7/src/pycurl.o -lcurl -o build/lib.macosx-10.8-intel-2.7/pycurl.so

Successfully installed pycurl
Cleaning up...

但是当我尝试导入pycurl时,我收到以下错误:

ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)

2 个答案:

答案 0 :(得分:2)

SSL backend error when using OpenSSL

重新发布

在阅读了他们的INSTALLATION文件之后,我能够通过设置环境变量并重新安装来解决我的问题

  • 删除现有的pycurl安装

    pip uninstall pycurl

  • 导出变量

    导出PYCURL_SSL_LIBRARY = openssl

  • 安装pycurl

    pip install pycurl

可能还有其他解决方案,但这对我来说非常适合在virtualenv和pip安装

答案 1 :(得分:1)

我遇到了同样的问题并以这种方式解决了问题。 首先我使用Python3并使用pip3,但同样适用于pip。

我意识到我没有安装或设置SSL,所以我去了https://www.openssl.org/source/并安装了最新的OpenSSL。 你用旧的unix方式安装它,你下载gzip文件。

tar -zxvf openssl-1.0.2n.tar.gz

(您的文件可能是不同的版本) 然后运行:

./Configure darwin64-x86_64-cc

(这仅适用于64位Mac架构。通常运行./configure) 然后:

make
make test
sudo make install

(使用sudo因为它可能需要创建文件夹)。 现在你已经安装了OpenSSL。您需要安装PyCurl并告诉它有关OpenSSL的头文件。我这样做了:

pip3 install pycurl --global-option=build_ext --global-option="-L/{OpenSSL-install-directory}/lib" --global-option="-I/{OpenSSL-install-directory}/include"

用您的实际路径替换{OpenSSL-install-directory}。我的 / usr / local / ssl

pip3 install pycurl --global-option=build_ext --global-option="-L/usr/local/ssl/lib" --global-option="-I/usr/local/ssl/include"

然后安装并工作。

使用以下资源拼凑这些: