Set Up Your Mac

Throughout the semester, you should prioritize using the computers (in TCL 217A and TCL 216) to work on your lab assignments. All the utilities you need have already been installed on them, and they have been set up so students do not face any platform-dependent issues. However, you may also work on your personal computer and, indeed, must do so during the first week.

This document gives you instructions on how to set up your personal Mac.

If you face any problems, please reach out to the CSCI 134 staff.

Note

Each person’s computer is different, and while these instructions work for most of them, there will inevitably be some unique issues and quirks that you may experience and learn how to workaround. If you encounter any such issues, please drop us a note.

Step 0. Verify macOS Version

  • You must have macOS 11 or 12 installed. If you have an older version, you need to upgrade it (for free). To find your macOS version, click on the “Apple” icon on the top left of the screen, and then on “About this Mac”.

  • If at any point in the setup process below you are prompted to install Xcode or Rosetta, please do so. These tools are essential to make this setup work.

Step 1. Add the Terminal Application to Your Dock

  • Although VS Code has a built-in terminal, it’s useful to know how to use a standalone terminal as well. Type “Terminal” into spotlight search to open the application.

    ../../_images/image14.png
  • Once it is open, we suggest you the choose the option to “Keep it in Dock”, so that it is easy to find in the future:

    ../../_images/image51.png
  • In the Terminal application, type whoami, it will print your username on your machine:

    ../../_images/image7.png

Step 2. Establish your CS credentials

Computer Science runs its own network of servers, with access limited to students with CS “credentials”. These credentials will be sent to you via email (with the Subject Line “Williams Computer Science Account Information”), and you are expected to change your password by following the instructions in that email. Notice that your CS username is slightly different from William’s username. Sharing your CS credentials with others is violation of the Honor Code.

To verify your credentials, type the following into the Terminal at the $ prompt, replacing your-username with your CS username (i.e., the one that starts with your graduation year).

ssh your-username@lohani.cs.williams.edu whoami

You may get the following message back:

The authenticity of host 'lohani.cs.williams.edu' can't be established.

  ECDSA key fingerprint is ....

  Are you sure you want to continue connecting (yes/no/[fingerprint])?

This is normal whenever you access a machine for the first time. If this happens, type yes, and press return/enter.

You will be asked for your CS password: provide it. Note that for security reasons, you will not see anything you type. After you press Enter, if the server prints out your CS username, then your credentials are working correctly. If you have trouble with establishing access, please email csaccounts@williams.edu.

Step 3. Configure Git

Git is installed with the Mac operating system. It may, however, need to turn on various programming features on the Mac. In the Terminal window type:

git --version 

It may respond with a dialog box with the message the “git” command requires command line developer tools. Would you like to install the tools now? These tools are important. Press Install, agree to the license agreement, and then press Done when the installation is finished. (It may take some time, so make sure your machine is attached to power.)

Next, you should configure git with your email and username. Execute the following commands in the Terminal, replacing your-williams-id@williams.edu with your Williams email address (i.e., the one without your graduation year) and your-CS-username with your CS user name (i.e., the one with your graduation year in front).

git config --global user.email 'your-williams-id@williams.edu'         
git config --global user.name 'your-CS-username'
git config --global push.default simple
git config --global pull.rebase false
git config --global core.editor nano

Step 4. Install Python

We’ll be using the Python programming language, version 3. You must install Python3. We suggest you do a fresh install even if you have an older Python version available.

  • Go to https://www.python.org/downloads/. It should give you a download specific to your machine. Be sure the download option’s version number starts with 3.10. Once downloaded, click and install the package. Provide your Mac password, if necessary, during installation.

  • After the installation, a Finder window opens to the Python 3.10 applications. It contains two useful scripts we suggest you run: (a) Double-click on Install Certificates.command. This will be helpful in establishing secure connections. When it is finished, dismiss the window. (b) Double-click on Update Shell Profile.command. This will make sure this version of Python is the preferred version.

  • After the installation, exit out of all applications, including the Terminal.

  • Reopen the terminal window and type:

    python3 --version 
    

    This should report the version you just installed, which will likely be Python 3.10.5 or something similar.

  • Upgrade the Python package installer, pip3. In the Terminal window type the following and enter your personal Mac password as necessary.

    pip3 install --upgrade pip
    

    Note that the above command is installing new applications on your computer.

  • Now that pip3 is available, we can use it to install Python packages that we will need this semester. Run the following installation commands:

    pip3 install jupyterlab
    pip3 install matplotlib
    

Step 5. Install VS Code

You need to install VS Code as an editor for your programs. Download it from https://code.visualstudio.com/. Installation should be straight forward. Make sure to drag VS Code to the Applications folder, making it available in the macOS Launchpad. If necessary, you can find detailed instructions for installation on the CSCI 136 webpage.

While not necessary for CS 134, if you would like to explore more advanced Python support in VS Code, you can follow these instructions. You should not install any extensions other than the VS Code Python extension published by Microsoft.

Step 6. Setup CS134 Folder

Now are you ready to create your CS134 directory on your computer. Unix directories correspond to folders in your Mac or Windows operating system. You will be creating many files on your computer for this class. We suggest that you put all of your work in a single folder, called cs134, located in your home directory. You can navigate to your home directory from within the Ubuntu terminal as follows:

  • Open the Terminal, and run the command pwd (print working directory). This tells you the path of your current working directory

    ../../_images/image21.png

    As you can see above, by default you will likely be in your home directory under your username. This is a good place to create your new cs134 directory. You can always navigate to your home directory, by typing the following (~ stands for home directory).

    cd ~
    
  • You can create your cs134 directory using the mkdir cs134 (short for make directory). Now if you use the command ls to list the contents of your current directory, you should see the newly created cs134 folder.

    ../../_images/image31.png
  • We can navigate into the folder with the command cd cs134 (short for change directory). Since this is an empty folder right now, if you type ls, it will not show any contents.

    ../../_images/image61.png
  • Now that you have created your cs134 folder, this is where you should always navigate to before you clone all your lab files.

That’s it! You are now ready to work on your assignments on your personal computer!