Python2.7,3.4的pip安装/升级错误

时间:2015-11-05 17:16:50

标签: python pip

Python Version=2.7, 3.4 所以我正在尝试更新pip,因为我在终端中收到以下消息。     您正在使用pip版本7.0.3,但版本7.1.2可用。     您应该考虑通过'pip install --upgrade pip'命令进行升级。

和此。

Collecting pip
Using cached pip-7.1.2-py2.py3-none-any.whl 
Installing collected packages: pip
Found existing installation: pip 7.0.3
Uninstalling pip-7.0.3:

然后我收到错误消息

  Exception:
  Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/commands/install.py", line 297, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_set.py", line 616, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 721, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/utils/__init__.py", line 314, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move
    rmtree(src)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree
    os.remove(fullname)
  OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/EGG-INFO/dependency_links.txt'

如何解决此错误?

2 个答案:

答案 0 :(得分:1)

安装需要您不具备的文件权限。 以sudo(sudo pip install ...)或以root用户身份运行。您将需要root密码。

unix标准文件系统层次结构是普通用户(甚至是管理员)对其homedir之外的大多数地方没有写权限。改变"全球"您需要具有更高权限的层次结构的路径。 root通常是高权限用户。通过在sudo前面添加命令来运行命令意味着将其作为另一个用户运行并且通常具有root权限,然后它可以写入pip尝试安装的/ Library这样的地方。

有关该标准的更多信息:https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

答案 1 :(得分:0)

尝试从以下位置删除 pip-7.0.3-py2.7.egg pip .pth * /Library/Python/2.7/site-packages / 然后尝试在终端中执行 pip install --upgrade pip 命令