python - sudo easy_install pip 不工作

标签 python pip easy-install

我在 mac 上执行 sudo easy_install pip 命令时遇到问题。我不在防火墙后面。我正在使用 python 版本 2.7.10。 macOS Sierra 的版本是 10.12.4。这是我收到的错误:

Searching for pip
Reading https://pypi.python.org/simple/pip/
Download error on https://pypi.python.org/simple/pip/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')

最佳答案

我找到了使用 brew 安装 pyenv 的解决方案。找到解决方案 here但我只需要它使用 pip 时的部分。

# Install PyEnv (https://github.com/pyenv/pyenv#installation)
$ brew update
$ brew install pyenv

# Initialize pyenv using bash_profile
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi\nexport PATH="~/.pyenv/bin:$PATH"' >> ~/.bash_profile
# or using zshrc
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi\nexport PATH="~/.pyenv/bin:$PATH"' >> ~/.zshrc

# restart the shell
$ exec "$SHELL"

# Install Python 2.7
$ pyenv install 2.7.14
$ pyenv local 2.7.14

完成这些步骤后,我再次运行 sudo easy_install pip 发现了!有效。

关于python - sudo easy_install pip 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50616037/

相关文章:

python - 如何配置 IPython 在 Windows 上使用 gvim?

python - 如果脚本失败则引发异常

matplotlib - 使用 pypi 安装最新的 matplotlib 版本

python - 在项目 VCS 中保留 Python GAE 依赖项的最佳实践

python - Python 的三引号字符串是如何工作的?

python - 随机字典选择?

python - Docker 容器中缺少 python 包

python - 使用 Docker 的名称解析 [Errno -3] 暂时失败

python - 无法安装 fancyimpute 以在 Jupyter 中使用

linux - 如何让easy_install升级到正确的目录?