I am transforming from windows to Macos and want to install python. It came with an old version of python 2.7 in the computer, so I download python 3 using the pyenv install
command. But when I input python --version
, I still got the old version. Why is that? And I can't install pip
either. Anybody knows why?

- 985
- 2
- 13
- 24
-
5The existing Python 2.7 is being used by the operating system. You can't (and shouldn't) upgrade that. Your new interpreter can be used by typing `python3` or using the full path (i.e. `/foo/bar/bin/python3`). – Selcuk Nov 05 '20 at 00:39
-
@Selcuk Thank you! So does that mean for all python command, I need to use `python3 --version`, etc? – Yingqi Nov 05 '20 at 02:28
-
1Whenever you want to use Python 3, yes. You can also use the shebang method for your own scripts: https://stackoverflow.com/questions/7670303/purpose-of-usr-bin-python3 – Selcuk Nov 05 '20 at 02:32
-
The above method did not change the output of python --version for me (using a mac Big Sur OS). The accepted solution of [this post](https://stackoverflow.com/questions/58051467/fixing-path-for-python-libraries-using-bash) helped. It seems like the PATH that is referred to for finding python environment needs to be modified in ~/.bashrc or **~/.zshrc** (for newer macOS users). – Parsa Rav Aug 03 '21 at 15:54
3 Answers
If you have installed python 3 (check it by running python3 --version
), you can set python3 as a default python version by creating a symbolic link.
run ls -l /usr/local/bin/python*
to see where all versions are installed.
lrwxr-xr-x 1 root wheel 69 May 10 2019 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3
lrwxr-xr-x 1 root wheel 76 May 10 2019 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config
lrwxr-xr-x 1 root wheel 71 May 10 2019 /usr/local/bin/python3.7 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
lrwxr-xr-x 1 root wheel 78 May 10 2019 /usr/local/bin/python3.7-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
lrwxr-xr-x 1 root wheel 72 May 10 2019 /usr/local/bin/python3.7m -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m
lrwxr-xr-x 1 root wheel 79 May 10 2019 /usr/local/bin/python3.7m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config
The output is like above, now you just need to choose the version you want from the ones which end with ...python3.X
not ...-config
or ...python3.Xm
, and create a symbolic link to it.
For example, you have chosen python3.7
to run as a default version, now it's time to create the symbolic link by running:
ln -s -f /usr/local/bin/python3.7 /usr/local/bin/python
now if you run python --version
its output should be 3.7

- 134
- 1
- 5
To add on to @Threem's answer, if you have the same issue with pip and pip3 (python's package manager) then you can run the following:
ls -l /usr/local/bin/pip*
You'll see something similar to his answer, but with pip instead of python.
Then you can create a symbolic link the same way.
ln -s -f /usr/local/bin/pip3.10 /usr/local/bin/pip
Now if you run
pip --version
you'll get your pip3 version.

- 2,609
- 1
- 29
- 41

- 481
- 2
- 16
If anyone gets hit with the "permission denied" error you can instead just do:
alias python=python3

- 1
- 1