【问题标题】:Python and Pip not in syncPython 和 Pip 不同步
【发布时间】:2017-02-23 10:52:21
【问题描述】:

我正在使用预装了 python 2.7.6 的远程 linux 服务器。我想升级到 python 2.7.12(因为下面显示的一些 ssl 错误,我无法在 2.7.6 上安装一些库)。

我从源代码下载并编译并安装了 2.7.12,python2.7 打开 2.7.12。但是,我在使用 pip 时仍然收到更新 python 版本警告。 pip 似乎没有与 2.7.12 同步并继续为 2.7.6 提供服务,我无法在系统中找到其他 pip 安装。

我只想要一个 pip/pip2/pip2.7 正常工作的 python2.7.x 工作版本。

    /usr/local/lib/python2.7/dist-packages/pip-8.1.2-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip-8.1.2-py2.7.egg/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning

【问题讨论】:

  • 那台机器有openSSL吗?大多数情况下,python 会发出此警告,但仍会安装软件包。它能够将东西安装到您的系统中吗?
  • 不,不是。我尝试安装sklearn,它抛出了很多异常,现在它显示它已安装。但是 sklearn 坏了,不能工作。
  • 能否安装 urllib3、pyOpenSSL 和 openSSL,然后再尝试安装软件包?
  • @ar7 我已经看到了这个错误,如果我没记错的话,这是一个过时的pip 的问题,正如 OP 猜测的那样。升级pip 通常是解决方案。
  • 我不明白您的错误消息中的路径:它们似乎指向最近的 pip 版本和手动安装的 Python 2。这对我来说并不表示 Python 2.7.6。

标签: python linux python-2.7 pip


【解决方案1】:

以这种方式升级(并自动重新安装)pip:

/path/to/python2.7.12 -m pip install pip --upgrade

-m 标志加载对应的模块,在 pip 的情况下会执行pip(感谢the power of the __main__ module inside the package)。

安装后,您当前的pip 也应该是最新的。


或者,你可以运行

/path/to/python2.7.12 /path/to/pip2 install pip --upgrade

注意:请注意您正在运行的 pippython2:可能会有 /usr/bin/python 和 /usr/bin/pipnext to the ones you installed in/usr/local/. The ones in/usr /bin` 应该在标准系统更新之后更新,如果有的话。

【讨论】:

    【解决方案2】:

    感谢@Evert,在我尝试查看您的解决方案之前,

    curl -O https://bootstrap.pypa.io/get-pip.py
    python27 get-pip.py
    

    这解决了我的问题,我能够使用 pip/pip2.7 将库安装到 2.7.12

    我早些时候尝试过python2.7 -m pip install package-name,但我得到了pip not found

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-05
      • 2015-12-19
      • 1970-01-01
      相关资源
      最近更新 更多