2

I'm trying to add python3 to my path by adding a symlink but it's erroring and I'm not sure why.

/usr/bin $ sudo su
sh-3.2# ln -s /Library/Frameworks/Python.framework/Versions/3.7/bin/python3  /usr/bin/python3
ln: /usr/bin/python3: Operation not permitted

sh-3.2# whoami
root

sh-3.2# ls -la | head -n 2
total 139064
drwxr-xr-x  977 root   wheel     31264 24 Jul  2018 .

* Edit *

I have symlinked from /usr/local/bin/python3 so that's fine.

4

/usr/bin is, as a lot of directories installed by default, protected by SIP and can't be modified by any user. There are ways to disable SIP, but the better approach is to use the directories beneath /usr/local for user-installed things

sudo mkdir /usr/local/bin
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 /usr/local/bin/
sudo sh -c 'grep -q "/usr/local/bin" /etc/paths || echo "/usr/local/bin" >> /etc/paths'

The last line will make sure that /usr/local/bin is part of PATH for all shells started/Terminal tabs created after the line has been executed.

  • Thank you. Is there a way to know what directories are protected by SIP from the command line? @nohillside – AJP Apr 30 at 10:00
  • 1
    @AJP Sure, see support.apple.com/en-us/HT204899. Or use ls -Ol (that's the letter O) – nohillside Apr 30 at 10:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .