Now that you understand what Python is and why it's a valuable language to learn, let's get it running on your macOS computer. Setting up a proper development environment is the first practical step towards writing and running your own Python programs.
macOS often includes an older version of Python pre-installed, primarily for compatibility with legacy system scripts. While convenient, this version might not be the one you want for active development. We strongly recommend installing the latest stable version directly from the official Python website to ensure you have access to the newest features, security updates, and consistent behavior across different projects.
Before installing, you can check if Python 3 is already available on your system and which version it is.
Applications
folder, inside the Utilities
subfolder. A quick way to open it is using Spotlight Search (Cmd + Spacebar) and typing "Terminal".python3 --version
If Python 3 is installed and configured correctly, you'll see output like Python 3.x.y
(where x
and y
are version numbers). If you get a "command not found" error, or if the version shown is very old, proceed with the installation steps below.python --version
You'll likely see Python 2.7.x
. It's important not to use this version for modern Python development. Always use the python3
command (or just python
after installing the official version, as we'll see).Even if python3 --version
shows a recent version, using the official installer ensures you have the standard setup expected by many tools and tutorials.
.pkg
file (e.g., python-3.11.5-macos11.pkg
). Download the latest stable release; avoid pre-releases or beta versions unless you have a specific reason..pkg
file (usually in your Downloads
folder) and double-click it to start the installation wizard./Library/Frameworks/Python.framework
). You generally don't need to customize the location.The installer typically configures your system so that the python3
command points to the newly installed version.
It's important to confirm that the installation worked and that your system recognizes the new Python version.
python3 --version
You should now see the specific version number you just installed (e.g., Python 3.11.5
). If you still see an old version or get an error, double-check the installation steps or consult the Python documentation for troubleshooting.pip
is the package installer for Python, used to add libraries and tools. It's included with the official Python installer. Verify it by running:
pip3 --version
This should output the version of pip bundled with your Python installation and its location. We'll use pip
later in the course to install external packages.With Python installed, you can now interact with it directly using its Read-Eval-Print Loop (REPL). This is a great way to experiment with simple code snippets.
python3
and press Enter.
python3
>>>
. This means Python is waiting for you to type commands.>>> print("Hello from Python on macOS!")
Python will execute the command immediately and display the output:
Hello from Python on macOS!
>>>
The >>>
prompt reappears, ready for your next command.exit()
and press Enter, or press Ctrl+D
.
>>> exit()
Congratulations! You have successfully installed Python on your macOS system, verified the installation, and interacted with the Python REPL. You now have a working environment ready for writing and running your first Python scripts, which we will cover shortly.
© 2025 ApX Machine Learning