【问题标题】:SSL error installing pycurl after SSL is set设置 SSL 后安装 pycurl 时出现 SSL 错误
【发布时间】:2014-02-24 13:45:26
【问题描述】:

只是一些信息开始:​​

  • 我正在运行 Mac OS 10.7.5
  • 我安装了 curl 7.21.4(我相信附带了开发工具)
  • 我有 python 2.7.1

我一直在尝试安装 pycurl,但每次尝试运行它时,都会得到:

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

我首先使用 setup 安装了 pycurl:

python setup.py install

这不起作用(因为没有配置 SSL)。

在尝试之前我已经卸载了 pycurl (sudo rm -rf /Library/Python/2.7/site-packages/pycurl*):

export PYCURL_SSL_LIBRARY=openssl
easy-install pycurl

在尝试之前再次:

python setup.py --with-ssl install

但是,我仍然收到与未编译 ssl 相同的错误。好像所有指令都忽略了我的尝试。

setup.py 在安装时完全没有抱怨,但在我设置 PYCURL_SSL_LIBRARY 环境变量后,easy install 会打印此消息:

src/pycurl.c:151:4: warning: #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"

这似乎表明它完全忽略了我刚刚告诉它使用 openssl 安装的事实......

我在设置中缺少什么吗?

【问题讨论】:

    标签: python easy-install pycurl


    【解决方案1】:

    我必须在 CentOS 7 上使用以下内容:

    sudo pip install --no-cache-dir --compile --ignore-installed --install-option="--with-nss" pycurl

    不需要uninstall 或设置PYCURL_SSL_LIBRARY。一切都融入了这一行。

    【讨论】:

    • 接受的答案并没有为我解决这个问题,你的解决了。谢谢!
    • 对我来说也一样。运行 RHEL7 并且需要运行相同的命令。建议的解决方案在安装时没有重新编译,因此 PYCURL_SSL_LIBRARY 值似乎被忽略了以下也可以工作:# export PYCURL_SSL_LIBRARY=nss# pip install --no-cache-dir --compile pycurl
    【解决方案2】:

    当你得到:
    failed: ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (none/other)

    您需要在正确设置 PYCURL_SSL_LIBRARY 的情况下重新编译 pycurl。 重新安装似乎是一个两阶段的过程。

    似乎 pip 在某个地方下载了这些东西,对其进行编译,然后将其放在 python 可以使用它的地方。 如果您在缓存中有已编译的版本,那么您实际上会被搞砸,因为它不会重新编译。无论 PYCURL_SSL_LIBRARY 变量中的内容是什么,它都“给”python 相同的东西。

    解决方法很简单,擦除缓存强制重新编译。根据您的操作系统,缓存可能位于多个位置。您可以使用存在 setup.py 的事实去搜索它。它有 PACKAGE = "pycurl" 字符串。但是没有必要为所有这些麻烦。最新的 pip 版本支持 install --compile 选项。

    升级到最新的点子:
    pip install --upgrade pip #Healthy anyway

    删除当前的pycurl:
    pip uninstall pycurl

    根据需要设置 PYCURL_SSL_LIBRARY:
    export PYCURL_SSL_LIBRARY=nss #For me this was the required setting

    终于运行
    pip install --compile pycurl

    请注意,对于编译过程中所需的各种头文件,您可能需要一些 -devel 包。

    【讨论】:

    • 此解决方案并非在所有情况下都有效。添加--no-cache-dir 以适合我的方式编译它。 # pip install --no-cache-dir --compile pycurl
    • 我收到了pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other),尽管我已经按照所有步骤操作,甚至使用 brew 重新安装了 openssl 并尝试了 --no-cache-dir。这让我发疯了
    【解决方案3】:

    对于 mac, sudo pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl 谢谢

    【讨论】:

    • 为我工作,似乎我在 macOS Catalina 上需要这个额外的选项(也许是额外的 --install-option="--with-openssl")
    【解决方案4】:

    您还需要用于 openssl 的“开发工具”(头文件/库)。

    也可以试试 pycurl 的最新版本,它可能开箱即用。

    【讨论】:

      【解决方案5】:

      要对@Andrei 给出的正确答案进行一点更新,我想说最后一个命令需要通过将 no-cache-dir 添加到 pip install 来强制重新下载和设置执行

      pip install --no-cache-dir --compile pycurl
      

      这将强制完成编译。

      【讨论】:

        【解决方案6】:

        假设您通过自制软件安装了 openssl,请检查 brew info openssl。您可能需要通过 env-vars 包含一些编译标志才能使用它,例如许多“仅桶”库。

        【讨论】:

          猜你喜欢
          • 2016-05-13
          • 1970-01-01
          • 2018-08-05
          • 1970-01-01
          • 1970-01-01
          • 2020-05-15
          • 2021-09-13
          • 2023-04-11
          • 2021-03-05
          相关资源
          最近更新 更多