Installation on Mac
Installation on Mac#
We’ll be typing at the “terminal” prompt often during the class. In macOS, the
program giving the terminal prompt is
Terminal.app. It comes installed
Press the Command key and the spacebar at the same time to open the Spotlight search box. (You can also click on the magnifier glass icon in menu bar towards the right). Type “terminal” and press return to open Terminal.app. You should get a terminal window. Consider pinning Terminal.app to your dock by right-clicking on the Terminal icon in the dock, chose “Options” and “Keep in dock”.
Git comes with the Apple macOS command line tools.
Install these by typing:
in Terminal.app. If you don’t have the command line tools, you will get a dialog box like this:
Select “Install”. You may need to wait a while for that to complete.
When it has run, check you can run the
git command with this, in Terminal.app:
It should show you the Git help message.
Homebrew is “The missing package manager for macOS”. It is a system for installing many open-source software packages on macOS. We recommend Homebrew to any serious Mac user; you will need it for the instructions on this page.
To install Homebrew, follow the instructions on the homebrew home page.
Mac actually comes with a version of Python for its own use, but it’s nearly always better to install your own version, for your use.
First, install with Homebrew.
In Terminal.app, type:
brew install python
Check carefully for any error messages about failure, like this:
Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink bin/2to3 Target /usr/local/bin/2to3 already exists. You may want to remove it: rm '/usr/local/bin/2to3'
2to3 command above is just one command that Python installs to your
If you see a message like that, it means you had another, presumably older,
copy of Python and its associated commands installed in your
folder. Fix the problem by forcing Homebrew to overwrite the old copy, with
the instructions you will see further down that message:
brew link --overwrite python
Set up Python for your Terminal#
Next, open the file
~/.bash_profile with a text editor, for example, like this:
touch ~/.bash_profile open -a TextEdit ~/.bash_profile
Scroll to the end of the file, and add this line:
Be very careful that TextEdit doesn’t automatically capitalize
Export. Correct it again to lower case if it does.
Save, and close the text editor. Close Terminal.app Start Terminal.app again, and confirm you are looking at the right Python:
You should see: