The Python's default version is 2.7.0 on my MacOS,
python --version
Python 2.7.16
python3 --version
Python 3.9.9
and Python3 has been installed via homebrew, how to make it as default? I want to make it point to the correct directory instead of using alias.
type -a python
python is /usr/bin/python
type -a python3
python3 is /opt/homebrew/bin/python3
python3 is /usr/bin/python3
Also, it would be very grateful if you can help with pip also. So far only pip3 has been installed.
type -a pip
pip not found
type -a pip3
pip3 is /opt/homebrew/bin/pip3
pip3 is /usr/bin/pip3
Generally doing this can impact legacy programs reliant on Python 2.x , but the below was taken from a website to demonstrate how to change the default .
How to set Python3 as a default python version on MacOS?
This has been answered on this website, and the below are snippets from the website
Look where python is installed & view the output.
ls -l /usr/local/bin/python*
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
python --version
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.