升级权限被拒绝:如何在Mac OS X上升级pip?

时间:2015-05-01 06:05:55

标签: python macos pip

我是Mac OS X的新手。我想为python编程设置一个环境。 我正在使用pip来管理第三方软件包。

我用easy_install安装了pip。

sudo easy_install pip

我尝试将pip从6.1.0升级到6.1.1 。但是,我的请求被拒绝了,我得到了以下消息。

$ pip install --upgrade pip
You are using pip version 6.1.0, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip
Using cached pip-6.1.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 6.1.0
Uninstalling pip-6.1.0:
  Successfully uninstalled pip-6.1.0
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/basecommand.py", line 246, in main
  status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/commands/install.py", line 352, in run
  root=options.root_path,
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/req/req_set.py", line 711, in install
  **kwargs
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/req/req_install.py", line 806, in install
  self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/req/req_install.py", line 1007, in move_wheel_files
  isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/wheel.py", line 347, in move_wheel_files
  generated.extend(maker.make(spec))
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/_vendor/distlib/scripts.py", line 323, in make
  self._make_script(entry, filenames, options=options)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/_vendor/distlib/scripts.py", line 227, in _make_script
  self._write_script(scriptnames, shebang, script, filenames, ext)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/_vendor/distlib/scripts.py", line 201, in _write_script
  self._fileop.write_binary_file(outname, script_bytes)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.0-py2.7.egg/pip/_vendor/distlib/util.py", line 388, in write_binary_file
  with open(path, 'wb') as f:
IOError: [Errno 13] Permission denied: '/usr/local/bin/pip'

似乎我没有权限升级pip。我认为这不是缺乏依赖包的问题。我正在使用的OS X系统是OS X 10.10.3。我正在使用Python 2.7.9。

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:14)

您使用sudo easy_install pip安装了它,这使得root用户创建了pip

升级时,您还应该使用:

sudo pip install --upgrade pip