我正在尝试升级我的iMac上的pip,但我一直收到权限被拒绝错误。我是管理员,所以我不知道我做错了什么。
iMac:~ me$ pip install --upgrade pip
You are using pip version 6.0.8, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.1.2-py2.py3-none-any.whl#md5=5ff9fec0be479e4e36df467556deed4d
Downloading pip-7.1.2-py2.py3-none-any.whl (1.1MB)
100% |################################| 1.1MB 181kB/s
Installing collected packages: pip
Found existing installation: pip 6.0.8
Uninstalling pip-6.0.8:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_set.py", line 543, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_install.py", line 667, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/utils/__init__.py", line 316, 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-6.0.8-py2.7.egg/EGG-INFO/dependency_links.txt'
我不知道我在这里做错了什么,因为升级看起来相当简单。
谢谢,
答案 0 :(得分:15)
pip
安装需要提升
sudo pip install --upgrade pip
仅仅因为您当前正在使用管理员帐户并不意味着该命令将以提升运行,除非您指定sudo
答案 1 :(得分:2)
您必须使用sudo
,因为您正在升级pip“全局”。我更喜欢安装Homebrew并让Homebrew管理所有内容。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install python
,它也安装了pip。 使用此设置,所有内容都在本地安装,不需要您运行sudo
。
我希望这会有所帮助。
答案 2 :(得分:1)
您可以采取以下两种方式之一:
chown -R user /path/to/file
可在此SO帖子中找到更详细的信息,但与处理同一问题的确切问题无关pip install --upgrade pip
。但是,许多用户会建议不要这样做。