修复mac预安装的python

时间:2016-06-29 12:36:31

标签: python macos

最近我尝试安装一些软件包或更新pip,弹出类似的错误消息。

Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_install.py", line 716, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/utils/__init__.py", line 315, in renames
    shutil.move(old, new)
  File `enter code here`"/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/Frameworks/Python.framework/Versions/2.7/bin/pip'

我认为这可能是因为在macport上不正确地卸载了python导致它,就像我尝试使用

更改不同的python一样
port select --list python

sudo port select --set "python name"

当我输入

which python

所有这些都导致

/opt/local/bin/python

它们都没有连接到框架。 我想问是否还有恢复mac预安装的python?

1 个答案:

答案 0 :(得分:0)

只需运行

即可解决问题
sudo pip install --upgrade pip