无法升级pip

时间:2016-12-15 20:24:38

标签: python python-2.7 terminal pip

我想安装一些库来学习机器学习。我说我需要升级pip,但是当我试图安装它时

$ pip install --upgrade pip
Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 8.1.2
    Uninstalling pip-8.1.2:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 736, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 303, in move
    os.unlink(src)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-8.1.2.dist-info/DESCRIPTION.rst'
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

5 个答案:

答案 0 :(得分:3)

除非使用virtualenv,否则必须使用sudo运行它。问题是您没有更改该模块的权限。使用sudo,您将授予管理员更新权限。

sudo pip install --upgrade pip

答案 1 :(得分:1)

错误

OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-8.1.2.dist-info/DESCRIPTION.rst'

显示您不能以普通用户身份升级pip,您必须以sudoer

运行它

sudo pip install --upgrade pip

答案 2 :(得分:1)

Windows:

1)关闭当前的命令提示符窗口。

2)再次打开它,但以管理员身份:右键单击并选择:“以管理员身份运行”

enter image description here

Linux或Unix:

以Tim和Haifeng提到的“ sudo”开始命令。

答案 3 :(得分:0)

升级点

在Linux或macOS上:

pip install -U pip

在Windows上:

python -m pip install -U pip

Source

答案 4 :(得分:-1)

<块引用>

错误:找不到满足升级要求的版本(来自版本:无) 错误:找不到要升级的匹配发行版

在cmd中输入这个来升级:

python -m pip install -U pip