By default MacOS ships with Python-2.-. But, I guess most of us have long back started to work with Python-3 and it is very irritating to run python3 every time instead of python in terminal. Here is how to do this.
Open the terminal (bash or zsh) whatever shell you are using.
Install python-3 using Homebrew (https://brew.sh).
brew install python
Look where it is installed.
ls -l /usr/local/bin/python*
The output is something like this:
lrwxr-xr-x 1 irfan admin 34 Nov 11 16:32 /usr/local/bin/python3 -> ../Cellar/python/3.7.5/bin/python3
lrwxr-xr-x 1 irfan admin 41 Nov 11 16:32 /usr/local/bin/python3-config -> ../Cellar/python/3.7.5/bin/python3-config
lrwxr-xr-x 1 irfan admin 36 Nov 11 16:32 /usr/local/bin/python3.7 -> ../Cellar/python/3.7.5/bin/python3.7
lrwxr-xr-x 1 irfan admin 43 Nov 11 16:32 /usr/local/bin/python3.7-config -> ../Cellar/python/3.7.5/bin/python3.7-config
lrwxr-xr-x 1 irfan admin 37 Nov 11 16:32 /usr/local/bin/python3.7m -> ../Cellar/python/3.7.5/bin/python3.7m
lrwxr-xr-x 1 irfan admin 44 Nov 11 16:32 /usr/local/bin/python3.7m-config -> ../Cellar/python/3.7.5/bin/python3.7m-config
Change the default python symlink to the version you want to use from above.
Note that, we only need to choose the one that end with python3.. Please avoid using the ones' that end with config or python3.m or python3.*m-config.
Below command shows how it should be done:
ln -s -f /usr/local/bin/python3.7 /usr/local/bin/python
Close the current terminal session or keep it that way and instead open a new terminal window (not tab). Run this:
python --version
You will get this:
Python 3.7.5
Hah! That's it. Happy coding!!
- 참고 : dev.to/malwarebo/how-to-set-python3-as-a-default-python-version-on-mac-4jjf
'개발' 카테고리의 다른 글
파이썬 - 자주 쓰는 Pandas 문법 (0) | 2021.03.01 |
---|---|
맥[mac] - cron Operation not permitted 에러 (0) | 2021.02.27 |
WebSocket (0) | 2021.02.18 |
WebFlux (0) | 2021.02.18 |
EHCache (0) | 2021.02.18 |