'unable to update python [duplicate]

When I type python --version, the output is "Python 2.7.18" I tried python3 --version, and the output is Python 3.10.4, how can update python to 3.10 without creating python 3?

I was expecting python's version to be 3.10.x and I tried brew upgrade, it didn't work. I'm on mac montery btw



Solution 1:[1]

Try this

`vi ~/.bash`

Then type out

alias python=python3

Save your file by pressing Esc -> type :wq

Then to update your shell environment

source ~/.bash

Another way you could try if you know what you are doing, is to go straight to your .bash_profile or .bashrc and write direct into it:

export PATH="/usr/local/opt/[email protected]/libexec/bin:$PATH"

change X and Y to your python version

Solution 2:[2]

The python 2 version is used by the system and it's recommended that you don't mess with it becauseyoua can seriously damage your ability to use your operatingsystem.

If you feel like you need to manage multiple python versions in your system you can use pyenv

This article here also simplifies the installation

Solution 3:[3]

Linux based system comes with Python 2 pre-installed for compatibility with legacy software. It's not recommended to make changes on it yourself. You might be breaking something.

For now, if you want to use Python 3, your option is to use the python3 command.

Alternatively, you may try the recently released (march, 14th) macOS Monterey 12.3. Acordinly to it's Release Notes, they are dropping the python 2 from the system. In this case, you should be able to safely install Python 3 and use it as just python at the command line.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rajiv Xavier
Solution 2 Ian
Solution 3 Ian