Mac 上的权限被拒绝

时间:2021-06-21 09:02:32

标签: python macos permissions version default

我想将 Mac 上 Python 的默认版本从 Python2 更改为 Python3。但是,当我尝试这样做时,它说权限被拒绝。这是我尝试过的:

ls -l /usr/local/bin/python*

输出是:

lrwxr-xr-x  1 root  wheel  69 Jun 21 10:41 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3
lrwxr-xr-x  1 root  wheel  76 Jun 21 10:41 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3-config
lrwxr-xr-x  1 root  wheel  71 Jun 21 10:41 /usr/local/bin/python3.9 -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
lrwxr-xr-x  1 root  wheel  78 Jun 21 10:41 /usr/local/bin/python3.9-config -> ../../../Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9-config

然后,我尝试了:

ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python

然而,这是出现的:

ln: /usr/local/bin/python: Permission denied

我应该如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

假设您是管理员,您只需要运行带有 sudo 的命令

sudo ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python

答案 1 :(得分:0)

要更改默认版本,您只需在终端中键入以下命令:

alias python=python3