I just set up Python on both my Mac laptop and Windows desktop, and I'm curious about some differences I'm noticing. When I run my programs, I can use either 'python' or 'python3' on Windows, and both commands work perfectly. But on Mac, it only recognizes 'python3', and 'python' results in an error. What could be the reason for this? Is it just a quirk of MacOS, or is Windows allowing a legacy version of Python to run?
6 Answers
You should check your PATH environment variable as well. On Windows, it's likely pointing to a Python installation that has created helpful links to the executable. Creating a virtual environment is also a good practice as it keeps your projects separate from system Python.
Back in the day, 'python' referred to Python 2, and 'python3' referred to Python 3. If you call 'python' on Mac, and it's not installed, you'll hit a wall. I tried making a symlink to get 'python' to refer to 'python3', but had to install Homebrew first to sort it out properly.
The difference you're seeing isn't about the terminal itself but rather how Python is set up on each system. On some setups, 'python' is linked to 'python3', while on others, it points to an older version, like Python 2. It's all about the configuration when you install Python on your system.
This really depends on how Python is installed on your system. It's best practice to use 'python3' to avoid issues since 'python' might still refer to Python 2. You can check out PEP 394 for more info on handling versions.
On Mac, there might be tools that still depend on Python 2, hence why 'python3' is the standard for modern usage now. Windows doesn't have that limitation since it doesn't require a specific Python version for the OS to function, so you can use whichever version you install.

It's true! I thought Python 2 was out of the picture by now since Python 3 has been around so long.