Home / 6.101 Infrastructure / macOS

Setting Up for 6.101 On macOS

You are not logged in.

Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.

1) Command Line§

Note that the instructions below (and throughout 6.101) will often refer to using your computer's command line to run programs. We don't expect you to be familiar with using the command line before starting 6.101, and we'll try our best to explain exactly what needs to be done. If you are not familiar with the command line, we suggest reading the section of our course readings about some command line basics before proceeding.

With time, using the command line will start to feel more comfortable. But it can feel like a lot, especially right away at the start of 6.101! If it feels overwhelming, please don't fret; we're here to help! If you have questions about any of the steps described on this page, please feel free to ask for help, either in person during lab hours, or over e-mail at 6.101-help@mit.edu.

2) Python§

Python is pre-installed on MacOS X, but it is often an older version. For this class, you will need Python 3.9 or newer (and we recommend 3.11).

First open a Terminal window (from the Applications/Utilities folder). Type python3 --version and see whether it says Python 3.11.x. If it does, you are all set! If not, follow the instructions below:

2.1) Install Python§

If you did not already have the right version Python installed, you will need to install it. You can get a Python installer here:

2.2) Test§

You can test the installation by running python3 --version and making sure that Python reports its version as 3.11.x.

Note: You may need to restart the terminal app for the version change to be reflected.

3) Text Editor or IDE§

You will also need a program for editing your Python source files. Depending on where you learned Python and how far along you are, you may or may not already have a preferred text editor (or Integrated Development Environment) for working with Python code. If you already have something you are familiar with, feel free to use that! If not, we recommend using the "IDLE" program (which is included with most Python installations) for editing your files.

4) Pytest§

For all labs, you will also need the pytest module installed to run our test cases. Certain labs may have additional requirements (which will be described in the writeups for those labs), but for now, pytest is all we'll need. You can install pytest from the command line using a command like the following:

$ pip3 install pytest

(depending on your setup, you may need to type pip instead of pip3; or you may need to include sudo at the front, i.e. sudo pip3 install pytest)

After having done so, if you make a small Python file containing only the line import pytest, then evaluating that file with Python should work without error.

You should also be able to run pytest from the command line. If you get an output that looks something like this, you are good to go:

============================= test session starts ==============================
platform darwin -- Python 3.11.1, pytest-7.2.1, pluggy-1.0.0

If you get an error that looks like PermissionError: [Errno 1] Operation not permitted, don't worry! That just means pytest was looking for tests and it ran into a directory it couldn't access. Your pytest installation is working properly.

If you don't see those lines, you might have instead gotten a warning from the pip3 install pytest command of the following form:

WARNING: The scripts py.test and pytest are installed in '...' which is not on PATH.

In this case, you'll want to add the specified directory to your PATH environment variable, or use python3 -m pytest as a workaround.

5) Lab Submission Script§

Throughout 6.101, every time you are ready to submit an assignment to our server to be officially tested and scored, you will run a program from the command line to make that submission.

5.1) Installing the Submission Script§

In order to be able to run the program, we will first need to install it on your machine. You should be able to do so using the following two commands. Note that the first will likely ask for a password; this will be your local password (the one you use to log into your computer). Note also that your password will not be displayed as you type, but that's normal.

$ sudo curl -o /usr/local/bin/6.101-submit https://py.mit.edu/_static/spring23/6.101-submit
$ sudo chmod a+rx /usr/local/bin/6.101-submit

You can test whether the installation succeeded by running the following command:

$ 6.101-submit -t

If everything is working, that command should have produced some output, ultimately ending with the message: "labs@py.mit.edu: Permission denied (publickey)." If you see that message, the script was installed successfully!

A Common Issue

If command '6.101-submit -t' fails and the error message refers to the /etc/ssh/ssh_config file with an error along the lines Bad configuration option gssapikeyexchange, follow the solution here.

5.2) Configuring SSH Keys§

The "permission denied" message from the previous step happened because, as of right now, we do not know how to tell that it is you who is running the submission script. In order to be able to tell who you are, we will need one or more "SSH public keys" from you (one for each machine you plan to submit from).

Depending on your previous experience, you may already have one or more SSH keys installed on your machine. You can test for their presence by running the following command:

$ cat ~/.ssh/*.pub

If that command produced any output (typically a line starting with ssh-), you already have an SSH key on your machine! In that case, copy-and-paste the output into this form in order to let us know about this SSH key.

If the command above did not produce any output, that's OK, too; it just means that we'll need to take a few steps to set up a new SSH key. You can do that by running the following command:

$ ssh-keygen -t ed25519

That command should ask you several questions. If you do not have a reason to change your answers to those questions, it should be fine to accept the default values for each (by hitting "Enter" at each question without typing anything). If you do choose a password here, be sure to remember it, as you will need to enter it every time you submit an assignment to the 6.101 server!

Once you have generated a key, re-run the command above (cat ~/.ssh/*.pub), and copy/paste the output into this form.

5.3) Testing§

Once we have your SSH public keys, running the following command should produce slightly different results from before:

$ 6.101-submit -t

Now it should report back your username, as well as your role within 6.101. If you see your username there, you should be all set!