Python3 (v3.x) vs Python (v3.x)

I have two different versions of Python on my mac (Ventura 13.4.1): Python (v3.9.6) and Python3 (v3.11.1) for reasons I don’t know. What’s the difference between them, and can I uninstall Python3 (as I’m used to Python (v3.x) on PC) and my script will still work the same?

Where are they located? You can use which python and which python3 to find this out.

It’s likely that one of these versions (probably the older one, but I don’t know for sure) was installed by MacOS. I wouldn’t use it because it is liable to get further modified by software updates and whatnot–I don’t know if they use python3 for any internal scripts[1] but I wouldn’t remove it either, it’s basically part of the OS and installing packages there could break things.

If you installed Python another way, that’s likely the second version you see. I would recommend using that one, to keep your own packages and work separate from the OS installation. Really I would recommend using that python solely as the base for managing other environments that contain per-project dependencies, but there are a variety of tools available for this (I use conda / mamba but people use all kinds of things).


  1. they used Python 2 for a long time but hopefully will update someday ↩︎

1 Like

Did you install either or both of them? If you have not taken any action to put Python on your computer, and it came with both versions, then that is a tech support question either for Apple or (if applicable) for whoever provided you with the computer. If you installed one but not the other, it is practically certain that the one you didn’t install is a part of the operating system.

Do not ever attempt to uninstall a Python version that you can’t account for installing. If it came with the operating system, it is very likely that critical operating system functionality depends on it, and has only been tested for a specific Python version. While the language strives to be fully backward compatible in terms of syntax (back to 3.0) and is fairly conservative with new features, important parts of the standard library do occasionally get deprecated and eventually removed.

As for “Python” vs “Python3”, these are only names that are assigned so that you can easily choose which one to use at the command line. There are many ways to get this behaviour. But both Python versions that you have are “Python 3.x”, and are perfectly suitable for writing code as you’re accustomed to doing. Each .x release of Python is accompanied by documentation summarizing new features and functionality.

1 Like

There is one version of python3 in /usr/bin/python3 you cannot remove it macOS will prevent that.

For the other version you have installed them. For example if you use homebrew that can account for a version.
You may also have installed a version downloaded from python.org.

As mentioned use which to fine the full path to your version and report back here for suggestions.
Which may simply come down to asking you to set your PATH so that your preferred python3 is at the front of the PATH. Look in ~/.zprofile i think for where the PATH is set.

1 Like

Thank you all for the detailed answers! I now understand that all Python programs are different distributions, together with their own packet manager. Didn’t realize that before.
So for the Python3 I probably installed that from the obscure place python.org:slight_smile: and likely the one to use. The other must have come preinstalled.

But what about libraries I install and upgrade? One project I work on uses pandas, and that should be independent of which Python distribution I use, right? So if they’re both updated, I should have exactly the same functionality on my PC at work as on my Mac at home having installed pandas, even if the package managers differ?

The only remaining “problem” I have is that I’m used to type “python <script.py>” which works fine on the PC, but makes me use an older, as I understood, preinstalled version on my Mac.

The specific executable that python points to in your terminal will depend on the current environment. You can use echo $PATH to view the path, which will show you the locations that the shell looks for commands, in order.

If you want python to refer to the version you installed yourself, rather than the OS version (which is a good idea), you can make sure that your path is set correctly by modifying the .zshrc file in your home directory:

export PATH=/path/to/wherever/you/installed/python:$PATH

This will insert the installed python path (you can find this with which python3) to the front of your path, so that the shell finds python there first.

If you are coming from Windows and new to a posix-style shell, it is worth spending more time getting familiar with how it works and where it searches for binaries. It will save you a lot of headaches in the long term.

1 Like

Continuing my journey of understanding the world of python…

If I start python in terminal:

Python 3.9.6 (default, May 7 2023, 23:32:44)
(check pandas version)
‘1.5.3’

And python3

Python 3.11.1 (v3.11.1:a7a450f84a, Dec 6 2022, 15:24:06)
(check pandas version)
‘1.5.2’

So, the pre-installed version 3.9 is more recently updated than the one with higher version no. What does those version numbers tell me? Are they even comparable, more than the ‘3’, 3.something?

The libraries obviously depend on the python distro, having a copy (possibly with different version number) of one and the same library for every distro installed?

Yes each install of python needs its own libraries for two reasons
each version of python looks in diffferent folders for its libraries
and library, especial those write in C only work against specific versions
of the python C API.

The versions follow semantic version scheme (semver), https://semver.org/
This 3.11 is newer the 3.9.

Use the python.org 3.11 is the best choice, ignore the version installed by Apple.

1 Like

It might well be more recently updated, but the update will have been a smaller update. The difference between 3.9.x and 3.11.x is additional features, but the difference between 3.9.5 and 3.9.6 is small bug fixes.

1 Like

Apple does not use pandas [1], so I am guessing that you installed both versions yourself at different times, by inadvertently calling different versions of pip.


  1. at least I don’t think so. My computer doesn’t have it installed in the system python ↩︎

Every installation of Python on your system is completely independent from the others, and can and does have its own completely separate suite of third-party libraries (empty by default) stored in the site-packages subdirectory. In your case, each one has the Pandas third-party library installed, and the version of that library is different between the two.

Each third-party library is responsible for its own versioning scheme, which has nothing to do with either the Python version or the version of any other third-party library. Any given version of any particular library could be, or not be, compatible with any given version of Python; to find out the compatibility matrix, you must read the documentation for that library. However, generally the built-in package manager (pip) will make sure you get a compatible version of the library (and any dependencies), and can be used to update easily. It’s just - completely separate, for each Python installation. Each Python installation comes with its own pip (unless special steps are taken to omit it), and that pip will install and update packages for that Python installation.