Set Up Your Computer

MacOS, Windows, or Linux?

Yes.

Sort of.

For this course, we will be working extensively with the command line and VS Code, which function similarly across all three major operating system, so you can use whichever OS you prefer or already have. Linux is the gold standard in scientific computing environments; most computing clusters, cloud servers, and neuroimaging pipelines run on it, so familiarity with its command line is invaluable. MacOS runs on a Unix variant under the hood, meaning the terminal experience is nearly identical, making it a convenient choice for researchers who want a polished laptop environment that translates well to work on Linux/Unix environments such as servers and clusters.

Windows has historically been the odd one out for scientific computing, but the Windows Subsystem for Linux (WSL) has changed this dramatically. The WSL lets you run a full Linux environment inside Windows, giving you access to the same tools and workflows. For our purposes, the key is having a working terminal and Python environment.

So if you are already using Unix/Linux, good news, you are all set, just some configuration things and some package installs and your computing environment will be ready for a modern course in coding / scientific computing.

If you are using MacOS, also good news, you may not know it but MacOS is based on a Unix variant, so with some small configuration things and some package installs, you will also be ready.

If you are using Windows, it will be ok. Something we will cover in this course is learning to use the terminal, learning about file systems, files, directories, and so on. On Linux/Unix and on MacOS (which is based on Unix) this is straightforward and you won’t need to do anything particularly special. On Windows however you will need to do some initial setup to install something called the Windows Subsystem for Linux (WSL). This will enable you to launch a Linux session within Windows, and follow along in the course with everyone else. It’s not such a big deal. Instructions are below.

PS: Personally I am most familiar with MacOS and Unix/Linux. I am quite unfamiliar with Windows.

Unix/Linux

Open up an Ubuntu terminal and (assuming Ubuntu Linux) update the system:

sudo apt update
sudo apt upgrade -y

and then install some necessary tools including git:

sudo apt install -y build-essential git curl

and then install the uv tool:

curl -LsSf https://astral.sh/uv/install.sh | sh

close your Terminal.

and then download Visual Studio Code and install it.

MacOS

Open up a terminal and install some necessary build tools:

xcode-select --install

Install the Homebrew package manager:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then close the terminal and open up a new one, and install some other necessary tools including git:

brew install git

Then install the uv tool:

curl -LsSf https://astral.sh/uv/install.sh | sh

close your Terminal.

and then download Visual Studio Code and install it.

If you want a nicer looking Terminal than the one that ships with MacOS you can try one of these:

Windows

First update Windows, I think you can access this by going to the Start menu and typing “update” and one of the options will be a system update.

Next, open up Powershell (again, go to the Start menu and type Powershell to access it) and type:

wsl --install

When it is done, reboot your computer.

Open up Powershell again and type:

wsl.exe --install Ubuntu

It will eventually ask you for a default Unix user account and password.

Close Powershell and any other junky windows that Windows may have opened.

Open Powershell and check to see which version of WSL is running:

wsl -l -v

if it shows version 1 instead of version 2 then switch:

wsl --set-version Ubuntu 2

Close Powershell and reboot the computer.

From your Start menu select “Ubuntu” and it should launch a terminal, which is now, running Ubuntu linux.

Now go through the steps above in the Unix/Linux section.

Check your setup

Create a new folder somewhere on your computer’s file system and name it Psych_9040, and then navigate inside of it.

Open Ubuntu:

mkdir Psych_9040
cd Psych_9040

Use uv to install a python environment

uv init --python 3.12

Add the numpy package

uv add numpy

Create a new empty file:

touch hello.py

and add some Python lines of code to it:

echo "import numpy as np" >> hello.py
echo "x = np.array ([2, 3, 5, 7, 11, 13, 17, 19, 23, 29])" >> hello.py
echo "y = np.sum(x)" >> hello.py
echo "print(f\"the sum of {x} is {y}\")" >> hello.py

and test the code:

uv run python hello.py

and you should see this output:

the sum of [ 2  3  5  7 11 13 17 19 23 29] is 129

Git/GitHub

We will be learning about and using code versioning with Git and GitHub, so you should sign up for a (free) GitHub account.