为 python2.7 安装 pip 时出错

为 python2.7 安装 pip 时出错

安装 pip (适用于 python2.7)时出现此错误:

$python get-pip.py

Collecting pip
  Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
    100% |████████████████████████████████| 1.2MB 294kB/s 
Collecting setuptools
  Downloading setuptools-20.6.7-py2.py3-none-any.whl (508kB)
    100% |████████████████████████████████| 512kB 504kB/s 
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 71kB 403kB/s 
Installing collected packages: pip, setuptools, wheel
Exception:
Traceback (most recent call last):
  File "/tmp/tmpCmiLCu/pip.zip/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/tmp/tmpCmiLCu/pip.zip/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/tmp/tmpCmiLCu/pip.zip/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/tmp/tmpCmiLCu/pip.zip/pip/req/req_install.py", line 835, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/tmp/tmpCmiLCu/pip.zip/pip/req/req_install.py", line 1030, in move_wheel_files
    isolated=self.isolated,
  File "/tmp/tmpCmiLCu/pip.zip/pip/wheel.py", line 344, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/tmp/tmpCmiLCu/pip.zip/pip/wheel.py", line 315, in clobber
    ensure_dir(destdir)
  File "/tmp/tmpCmiLCu/pip.zip/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pip'

答案1

错误提示权限被拒绝。您需要拥有 root 权限。命令应该是sudo python get-pip.py

答案2

跑步sudo apt-get install python-pip

相关内容