Category Archives: Python

Python Installation

Everyone’s favorite serpentine language (sorry Slytherin) can be installed on Mac. Thissssss is how I did it.

1. You’ll need a text editor. There are many out there, but I selected one that works on Mac, Windows, and Linux. I chose Atom which I downloaded from their website https://atom.io

2. You’ll need to download Python

3. You’ll need an IDE to edit and run your program. There are many out there. When I heard of Spyder’s┬áscience and data analysis libraries, I thought I’d give it a shot. I’ll be running the program below in the terminal.

 

To Install Python do the following:

  1. Open a terminal window
    • Mac comes with a pre-installed version of Python 2.x.xx
    • Check this by entering the following command
       python --version 
  2. To install Python 3 go to their official page (python.org/downloads) and select the download button
  3. Open the .pkg download and run through the installation widget.
    • Once completed use the following in the command in the terminal to verify installation
       python3 --version 

 

Write and run a program

  1. Open Atom text editor
  2. Type
 print('hello world') 
  1. Save the file with any name and the python file extension. For example Hello.py
  2. Run from the terminal
    • Ensure you’re in the directory where your file was saved
    • Run the program using the following command in the terminal based on the name the file was saved as.
 python3 hello.py