Python is an invaluable tool for data science and anyone in a data role. From data wrangling and acquisition, to running advanced machine learning models, its value spans across the development spectrum.
Python comes preinstalled on OS X and most Linux distributions. To access it from the command line run:
This will open up the Python REPL where you can execute Python commands.
Note, running ‘python‘ from the command line will open Python 2.7, a version which will be deprecated in 2020. Unless you have a requirement to use version 2.7, I suggest you commit to only using Python 3+.
On Windows, you’ll need to follow a few steps to get Python running correctly. I’ll cover them below.
The first step to getting Python working on Windows is downloading the appropriate installer from the Python site. As of the beginning of 2019, Python 3.7 is the latest stable release and the version we’ll install.
Once the installer has finished downloading, double click it to begin the installation. You will be asked standard questions during the installation that should be familiar if you’ve installed a program before. Selecting the default choices is fine for most users. However, there is one very important checkbox.
Be sure to check Add Python 3.7 to PATH.
Your path tells the system the location of important files and programs. If the following message sounds familiar to you:
'program_name' is not recognized as an internal or external command, operable program or batch file.
you’ve run something that wasn’t in your path. If you don’t add Python 3.7 to the path, your computer won’t know what or where Python is and you will receive that message.
Make sure it works
Once the installer has completed, start the Python REPL from the Windows command line by running:
After which you will see the following prompt:
If you’ve installed multiple versions of Python, and they’re correctly added to the path, you can switch between them using:
If you followed the installation directions above, your default version will be Python 3.7 and you’ll only need to switch versions if it’s necessary for legacy code.
Congratulations! You now have Python 3.7 working on your machine. Now go code something!