카테고리 없음

[Python] Mac에서 Python 기본 버전 변경하기

SweetDev 2021. 9. 23. 02:05

맥에는 디폴트로 파이썬 2.7.16이 깔려 있는데 이것때문에 터미널에 Python3로 쳐야 내가 설치한 버전이 나오는게 너무 불편했다...

 

 

which python3

명령어를 통해서 파이썬이 설치된 위치를 찾는다

 

/usr/bin 이길래 거기로 이동 했다. 

그리고 ls -l python*로 파이썬3의 심볼릭 링크를 찾으려고 했는데.. 뭔가 이상했다...

 

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

이렇게 해야하는건데...?

 

그냥 해봤는데

sudo로 해도 Operation Not permitted가 나왔다..ㅠ

 

 

 

왜???

Why can't I symlink into /usr/bin?

El Capitan's new System Integrity Protection feature prevents changes to several core parts of OS X, including most of /usr/, even by root.

How can I still add executable files to my path?

Local customizations, such as what you're doing, belong in /usr/local instead. The path /usr/local/bin doesn't exist by default, but you can create it and put custom binaries (and symlinks) in it:

sudo mkdir -p /usr/local/bin sudo ln -s /usr/bin/python2.7 /usr/local/bin/python2

Note that while /usr/local/bin doesn't exist by default, it is in the default PATH, so as soon as you create it, it'll be searched for commands.

 

 

 

 

ㅇㅎ.. /local/로 심볼릭링크를 달길 원하는군요...

너무 어려운것같은데

 

여기서 궁금한점! /usr/bin과 /usr/local/bin의 차이점은 뭘까?

/usr/bin에서는 콘솔에서 확장된 프로그램들이 들어가며, 대표적으로 sudo와 vi가 있다. /usr/local/bin에는 우리가 설치하는 프로그램이 들어가게 된다. /usr/bin은 OS 스크립트들의 영향을 받으므로, 직접 설치하는 프로그램이 /usr/bin에 위치하게 되면 다른 스크립트들에 의해 업그레이드 되거나 삭제될 수 있다고 한다.

 

 

일단 PATH설정으로 할 수 있는 방법도 있긴 한데 마음에 안들어서 보류...

깔끔하게 하는 방법 아시는분 알려주세용

 

[출처]

https://choseongho93.tistory.com/262

https://stackoverflow.com/questions/36730549/cannot-create-a-symlink-inside-of-usr-bin-even-as-sudo

https://medium.com/@jspark141515/python과-python-패키지는-어디에-설치될까-2f2f31fc9baf