HomeCourseModule 02 › The terminal — a friendly introduction

The terminal — a friendly introduction

Module 02 · Setting Up Your Environment9 min readBeginner

What you'll learn

  • Open the terminal on Mac and Windows
  • Navigate folders with cd
  • Install Python libraries with pip

The terminal is not as scary as it looks

The terminal is a text-based way to talk to your computer. You'll need it for exactly two things in this course: installing libraries (pip install ...), and occasionally running a Python script (python myscript.py). Five commands, and you're set.

How to open it

The five commands you actually need

1. pwd (Mac) / cd on its own (Windows) — "where am I?"

pwd
# /Users/yourname

Tells you which folder the terminal is currently looking at.

2. ls (Mac) / dir (Windows) — "what's in this folder?"

ls
# Documents  Desktop  Downloads  Music ...

3. cd folder_name — "move into this folder"

cd Desktop      # move into Desktop
cd ..           # move one folder up
cd ~            # go to your home folder (Mac/Linux)

4. mkdir new_folder_name — "make a new folder"

mkdir python-projects
cd python-projects

5. pip install <library> — install a Python library

pip install openpyxl

You'll see a stream of text as pip downloads and installs the library. When the prompt comes back, it's done.

Bonus: python myscript.py — run a script

python hello.py
# Hello from VS Code!
#   Line 1
#   Line 2
#   ...

Walkthrough: install a library

Open the terminal (or Anaconda Prompt on Windows)

Type a pip command

pip install xlsxwriter

Press Enter. Watch the lines scroll. When you see Successfully installed xlsxwriter-..., you're done.

Confirm it worked

Open a Jupyter notebook or a Python file and run:

import xlsxwriter
print(xlsxwriter.__version__)

You should see a version number, not a red error.

⚠️ "Command not found" on Mac
If pip isn't recognised, try pip3 instead, or open Anaconda Navigator → Environments → click the green ▶ next to base (root) → "Open Terminal", then run pip install ... from that terminal.
⚠️ Windows: must use the Anaconda Prompt
Regular Command Prompt may not see your Anaconda Python. Always launch the Anaconda Prompt from the Start menu for these commands.

Key takeaways

  • Five commands cover 95% of what you need: pwd, ls/dir, cd, mkdir, pip install.
  • On Windows, always use the Anaconda Prompt, not regular PowerShell.
  • pip install is how you add any extra library.

Five-minute hands-on

  1. Open your terminal (or Anaconda Prompt).
  2. Make a new folder on your Desktop called python-for-excel.
  3. cd into it.
  4. Run pip install xlsxwriter requests beautifulsoup4.
  5. You just installed three libraries we'll use later. Easy.
📹 Video walkthrough
A video walkthrough of this lesson will be embedded here. Until then, the written walkthrough above mirrors what the video will cover step-for-step.