Mac OS X 10.10.5升级pip后被卸载,无法重装求助
问题描述
补充说明:使用的系统为Mac OS X 10.10.5 Yosemite
这就是我从不更新pip的原因之一,我担心会出现这种情况并破坏向后兼容性……唉。
我升级pip后,一切突然崩溃,现在无法正常使用它。
之前执行pip install pandas的输出:
Last login: Thu May 24 10:52:09 on ttys000 Hi Jan ~> pip install pandas Requirement already satisfied: pandas in /usr/local/lib/python2.7/site-packages Requirement already satisfied: pytz>=2011k in /usr/local/lib/python2.7/site-packages (from pandas) Collecting python-dateutil>=2.5.0 (from pandas) /usr/local/lib/python2.7/site-packages/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.io/en/latest/security.html#snimissingwarning. SNIMissingWarning /usr/local/lib/python2.7/site-packages/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.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /usr/local/lib/python2.7/site-packages/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.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /usr/local/lib/python2.7/site-packages/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.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB) 100% |################################| 215kB 2.7MB/s Requirement already satisfied: numpy>=1.9.0 in /usr/local/lib/python2.7/site-packages (from pandas) Requirement already satisfied: six>=1.5 in /usr/local/lib/python2.7/site-packages (from python-dateutil>=2.5.0->pandas) Installing collected packages: python-dateutil Found existing installation: python-dateutil 2.4.2 Uninstalling python-dateutil-2.4.2: Successfully uninstalled python-dateutil-2.4.2 Successfully installed python-dateutil-2.7.3 You are using pip version 9.0.0, however version 10.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
随后执行升级pip的命令:
~> pip install --upgrade pip zsh: correct 'pip' to '.pip' [nyae]? n /usr/local/lib/python2.7/site-packages/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.io/en/latest/security.html#snimissingwarning. SNIMissingWarning /usr/local/lib/python2.7/site-packages/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.io/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning /usr/local/lib/python2.7/site-packages/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 vers
升级后pip被卸载,现在无法重新安装。
解决办法
别慌,在Mac OS X 10.10.5这种老系统上,Python 2.7和新版本pip确实存在兼容性问题,下面两个方法帮你找回pip:
方法一:用系统自带的easy_install恢复指定版本pip
你的Yosemite系统自带的Python 2.7应该配有easy_install工具,直接用它安装你之前能用的pip 9.0.0版本(避免新版本的兼容问题):
sudo easy_install pip==9.0.0
执行后输入管理员密码,等待安装完成就能正常使用pip了。
方法二:用get-pip.py安装兼容版本
如果easy_install也出问题,就用curl下载Python 2.7专用的get-pip脚本,再安装指定版本:
# 下载适配Python2.7的get-pip.py curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py # 安装指定版本的pip sudo python get-pip.py pip==9.0.0
安装完成后可以删除下载的get-pip.py文件。
后续注意事项
- 之后不要再升级pip到10.0.1及以上版本,因为Python 2.7已停止维护,新版本pip不再支持它,很容易再次崩溃。
- 如果需要新Python特性,建议用
pyenv这类工具安装独立的Python 3版本,避免修改系统自带的Python环境,减少兼容性风险。
内容的提问来源于stack exchange,提问作者Rainymood




