The default Python on OS X shouldn't be messed with as it's used by the OS itself. If your default is 2.6.1 then you must have Snow Leopard.
If you just install from the standard 3.1 disk image then you can invoke it using python3.1 from the terminal (you don't have to do any extra steps for this to work) and you can leave the plain python as 2.6.1.
macos - Updating Python on Mac - Stack Overflow
macos - How do I upgrade python on Mac? - Stack Overflow
Python Updating on macOS - Apple Community
Upgrading Python version on MacOS, any risks?
Videos
The default Python on OS X shouldn't be messed with as it's used by the OS itself. If your default is 2.6.1 then you must have Snow Leopard.
If you just install from the standard 3.1 disk image then you can invoke it using python3.1 from the terminal (you don't have to do any extra steps for this to work) and you can leave the plain python as 2.6.1.
brew install python--> install the latest Python.ls -l /usr/local/bin/python*--> List all Python versions installed on your system.ln -s -f /usr/local/bin/python[your-latest-version-just-installed] /usr/local/bin/python--> Change default Python version to the latest version.
- E.g:
ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python
- Restart terminal.
python --version--> Check Python version default again.
Ref: https://dev.to/malwarebo/how-to-set-python3-as-a-default-python-version-on-mac-4jjf
To upgrade Python on your Mac, you should avoid using pip as it is a package manager for Python libraries, not for Python itself. Instead, you can download the latest version of Python from the official Python website and install it. Alternatively, if you have Homebrew installed, you can use the command brew upgrade python to update to the latest version of Python. Or opt for Anaconda which is a package and environment manager which you can set your python version in.
The best way is to just download it from the website.
If you just want to update pip, you can use pip3 install --upgrade pip.
If you really want to use the CLI to update Python, make sure you have Homebrew installed and run brew install python. If you don't have Homebrew installed, first run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" then run the first command.
In almost all cases, this is a bad idea. Changing the system Python can and quite often will break some other packages depending on the previous environment or version. Upgrading from Python 3.10 to 3.13 means quite a few things have been changed and/or removed, making such problems likely.
So, how can you use a more modern version of Python?
One way ist the way you have already gone, installing it and accessing it via python3.13.
Another way is using the deadsnakes PPA, see e.g. this answer by Hannu (but refrain from overriding your system default).
And then there are multiple ways to get access to a specific Python version within a specific project, here is a small selection:
- Pyenv is the classic solution for this. It allows you to download and install basically any Python version (even alpha and beta) and activate them dynamically or use them as the base for a virtual environment.
- UV, a upcoming Python dependency manager, can manage Python versions as well. You just have to specify the desired Python version in a
.python_versionfile in your project root directory. - Conda, another dependency manager, but not limited to Python, can also manage multiple Python versions.
A simple "clean" way to install a more recent Python3 than present in Ubuntu is the deadsnakes ppa:
Howto set the default version:
https://www.debugpoint.com/install-python-3-12-ubuntu/
... at "Use Python 3.12 as the default Python3"
The basics for installation:
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.12
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
The ppa gets updated, so a more recent one may well be present;
also ALWAYS verify the correctness of what is stated above.
I would like to upgrade MacOS Sonoma from Python 3.9 to 3.11, is there any possible risk to this? Can I break anything?
Hello,
Previous to upgrade, when I run python3 --version from Terminal, I get Python 3.8.9. I then downloaded version 3.11.1 from python.org and ran the installer. I get a new folder called Python 3.11 within Applications. However, I still get Python 3.8.9 when running python3 --version from Terminal. I have tried closing and re-opening Terminal, but that doesn't change anything.
I have also tried running an app called Update Shell Profile.command that is within the Python 3.11 folder in Applications; by just double-clicking on it.
Any assistance on this would be appreciated.
Thanks,