Installation and setup of Python on a Mac might get tricky. In this tutorial we will install latest Python through its installer and select the right python version as far as macOS comes with built in python 2 version. We will then install necessary extensions for VS Code and set up the debugger. In order to work on a project, we will launch a virtual environment (pipenv) and download one of the most popular libraries for demonstration purposes.
Ways to setup Python
There are couple of different ways to set up Python and its work environment on a Mac. One of the most common ways is installing Anaconda, an open source distribution for data scientists to get started with Python and R. Anaconda includes Jupiter notebook and different libraries that makes it easy to get started with Python. But this is not what we will do.
Another way is installing Python with its installer setting up dedicated virtual environment for every project. You can install any text editor or IDE you prefer and hook it up with the Python version you want to use. In this tutorial we will be using MS Visual Studio Code. I will demonstrate how to set up Python extension and set up the debugger for VS Code.
To get python installer you will need to head to <code>python.org</code>, head to downloads section and get the latest version of it. At the moment of writing version 3.8.1 is the latest version. The installation process is simply straightforward.
As the installation finishes you can check what version of python you have on your machine. In you open Terminal and type <code>python –version</code> it will display Python 2.x.x. As already mentioned macOS has built in version two of python. With a default command of <code>python</code> we are referring to this built in version.