Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Last updated: 2026-09-30

Authored by Souvik Mandal, Ph.D.

Project Leader & Instructor, Computational Behavioral Sciences, LS100, FAS, Harvard University | Linkedin ID: souvik-mandal-phd


Introduction: What is Python?

Python is an open-source, high-level programming language known for its simplicity and versatility. It is a general-purpose language, meaning you can use it for almost any kind of programming – from developing software and web applications to data operations, scientific computing, to flight control and industrial applications. First released in 1991, Python has become one of the most popular and recommended languages for beginners and experts alike. Its syntax is designed to be highly readable (often resembling plain English), which makes it easy to learn and beginner-friendly. Python’s popularity is backed by a large, active community and a rich ecosystem of libraries for various domains like data science, machine learning, computer vision, automation, software & web development, etc. Most, if not all, top tech companies and research labs use Python in their technology stacks, and Python consistently ranks among the most-loved and in-demand programming technologies. In short, pick up your favorite thing that can be benefitted from computing / coding / programming, learn Python from that perspective, and the Python skills you will develop can open the doors to many other areas of computing.

Using Python: From Simple to Advanced Workflows

When starting out, there are multiple ways to set up and work with Python, each with its own pros and cons. Below we examine several approaches, from the simplest (no installation) to more complex development workflows:

Online (Cloud) Python Notebook Environments

One of the easiest ways to start coding in Python is through Notebooks on online Python environments like Google Colab, and Kaggle. We can write and run Python code in these notebooks through web browsers, just like any other website, with no installation on our computer.

When to use: Online notebooks are great for initial learning, short projects, or when you can’t install software on your device. Educators often use them so learners can focus on coding rather than environment setup. If you have internet access and want to start right away, this is the simplest route.

Standard Installation on Your Computer

Another approach is to install Python on your computer (computer is also called “machine” in this context) and run code locally (which means Python running on your computer). The official Python distribution can be downloaded from Python’s official website (https://www.python.org/downloads) for Windows, macOS, or Linux. This approach gives you a persistent Python setup on your machine.

When to use: Installing Python locally is recommended if you plan to do substantial work on your own machine, want the ability to save files locally, or if you have offline requirements. It’s the next step once you outgrow the simplicity of online notebooks and need more control or want to build larger projects.

Installing Locally using a Python Distribution (Anaconda for Data Science)

For learners interested in data science or scientific computing, an all-in-one distribution like Anaconda is a popular choice. Anaconda bundles Python with a collection of commonly used libraries (NumPy, Pandas, matplotlib, etc.) and includes tools like Jupyter Notebook and JupyterLab by default.

When to use: If your primary goal is data science or you want a hassle-free way to get a scientific Python stack, Anaconda is a good choice. It’s often used in academic settings for its convenience. However, for general programming or if you prefer a lean setup, the standard Python installation plus manual package installs might be preferable.

Integrated Development Environments (IDEs) and Code Editors

As you progress, you may want to use a more powerful code editor or IDE (Integrated Development Environment) for writing Python code. Free IDEs like Visual Studio Code (VS Code), PyCharm, or Spyder offer rich features like syntax highlighting, auto-completion, debugging, and project management. Most of these IDEs offer their Pro version for free to students and educators.

When to use: If you start working on multi-file projects, need to debug code, or just prefer a more feature-rich environment, an IDE is appropriate. Many beginners start with IDLE or simple text editors and then move to VS Code or PyCharm as they become more comfortable. Visual Studio Code in particular is a friendly stepping stone – you can use it just as a text editor initially, and gradually make use of its IDE features as needed.

Advanced Workflows: Virtual Environments and Cloud Deployment

For completeness, it’s worth mentioning what more advanced Python workflows look like (even if it’s beyond the initial learning phase):

In summary, beginners should start with the approach that gets them coding as easily as possible – an online notebook or a basic local install – and gradually adopt more sophisticated tools as needed. Python’s strength is that it scales with you: you can start with a single notebook cell and, down the road, end up building a complex cloud-deployed application using the same core language.

Installing Python On macOS (Apple M Silicon)

If you are using a Mac with an Apple Silicon chip (M1, M2, etc.), installing Python is straightforward. Newer versions of macOS (since macOS Catalina) do not come with a usable Python 3 installation by default [1], so you will need to install Python 3 yourself. There are a couple of methods:

Method 1: Install via Homebrew (Recommended for Developers). If you’re comfortable with the Terminal, you can use Homebrew, a package manager for macOS, to get Python. First, install Homebrew (if not already installed) by running the official install script in Terminal [1]. Then install Python by typing:

brew install python3

This will fetch the latest Python 3 version. Homebrew makes it easy to update Python later (brew upgrade python) and manages the installation for you.

Method 2: Download the Official Python Installer. The Python Software Foundation provides macOS installers on the official Python website. Visit the downloads page and click the “Download Python 3.XX.X” button for your operating system. Make sure to choose the universal installer package, which supports both Intel and Apple Silicon Macs (modern Python installers include native support for Apple’s Silicon chips). Download the .pkg file and run it, then follow the prompts through the installation wizard (the default settings are usually fine). You may be asked for your Mac login password to approve the install.

After installation completes, you can verify it was successful. One way is to open the Terminal (find it in Applications > Utilities) and type python3 --version (or python3 to enter the interactive shell) [26]. Another way is to use IDLE, the Integrated Development Environment that comes with Python. Find IDLE in your Applications (it might be in a folder called “Python 3.x”). Launch IDLE, and it will open a window with the Python prompt >>>. You can try typing a simple command like print("Hello, Python!") and see the output. If everything is installed correctly, IDLE will show the Python shell waiting for your commands.

Method 3: Install via Anaconda Distribution.
Anaconda is a popular all-in-one Python distribution designed for data science and machine learning. It comes with Python plus hundreds of commonly used libraries and tools already installed, including Jupyter Notebook and JupyterLab.

Pros:

Cons:

Installing Python on Windows

Installing Python on Windows is also easy, with two main options available. You can either use the Microsoft Store app or install Python from the official website. We’ll cover both:

Option 1: From Microsoft Store (Windows 10/11). Microsoft provides Python via the Windows Store, which is a quick way to get Python 3 set up without dealing with PATH settings or admin permissions. Simply open the Microsoft Store, search for Python 3. (look for the one published by the Python Software Foundation), and click Get/Install. This will install Python for your user account. The Store installation automatically configures your PATH, so you can immediately use the python command in PowerShell or Command Prompt. It also will automatically update Python when new versions are released. This method is recommended for beginners by Microsoft’s documentation because it’s simple and doesn’t require extra configuration. After installation, you can verify by opening a new PowerShell (or Command Prompt) and typing python --version to see the installed version. You should also find IDLE in your Start menu (e.g. “IDLE (Python 3.x)”) which you can launch to bring up the Python shell.

Option 2: Using Winget Winget (Windows Package Manager) is a command-line tool built into modern versions of Windows that lets you install apps quickly from Terminal or PowerShell. Open PowerShell and run winget install Python.Python.3 to install the latest Python 3 release. Winget handles downloading and installing Python for you, and this method is especially useful for learners who prefer terminal-based setup. For official step-by-step instructions, see Microsoft’s guide: Install Python with Winget.

Option 3: Using the Official Installer from Python.org Go to python.org/downloads and download the latest Windows installer (choose the 64-bit installer for modern PCs). Run the installer .exe file. Important: On the installer’s first screen, check the box that says “Add Python to PATH” (and optionally “Install launcher for all users”) before clicking “Install Now”. This ensures that the Python executable is added to your system PATH, which means you can use the python command from any terminal window. The installer will then copy Python onto your system. After a few minutes, you should see a success message.

During the Python installation on Windows, make sure to check the option to Add Python to PATH (as shown above). This will let you run python from the command line without extra steps.

Once installed, verify it by opening the Command Prompt (cmd.exe) and running python --version, which should display the Python 3 version. You can also launch the IDLE app (search for “IDLE” in Start) – if it opens and shows a Python shell window, the installation was successful. From the command line, the python (or python3) command will start the interactive interpreter, where you’ll see the >>> prompt. Type exit() or press Ctrl-Z then Enter to quit the interactive mode.

Option 4: Anaconda Distribution. If you prefer using Anaconda on Windows, download the Anaconda installer from anaconda.com (it’s a large .exe file). Running it will install Python and a suite of tools. Anaconda has its own Start menu entry (Anaconda Prompt, Jupyter Notebook, etc.). This is an alternative to the above, mainly for those focusing on scientific computing.

After installing via any method, you are ready to write and run Python code on Windows. If you plan to use a code editor like VS Code, be sure to install it and the Python extension as mentioned earlier. Visual Studio Code can detect your Python installation automatically, especially if Python is in the PATH.

Working with Python: Running Scripts and Notebooks

With Python installed (or an online environment ready), you can now start running Python code. There are a few common ways to use Python interactively or run programs:

When to use notebooks vs scripts: For learning and experimentation, notebooks are fantastic because you can run pieces of code in isolation and see results (graphs, data tables, etc.) immediately. Our guide will next have you use a Jupyter Notebook to practice Python concepts. On the other hand, if you’re writing a program that will be used as an application or needs to be packaged, you’d typically organize it into script files or modules. It’s common to use notebooks for exploration and then move code into .py files for deployment or larger projects.

Local setup: Python + venv + Jupyter

This is the recommended way to run the course notebooks on your own computer. You will create one project folder for the course, give it its own virtual environment (a private set of Python packages that won’t interfere with anything else on your computer), install the course packages, and launch Jupyter Notebook. You only do the full setup once; after that, getting back to work takes three short commands.

These steps work for any of the installation methods above (Homebrew, the official installer, Microsoft Store, or winget). If you installed Anaconda, skip to the Anaconda users note at the end of this section.

Step 1: Check that Python works

macOS:

python3 --version

Windows:

python --version

You should see something like Python 3.11.9. If you get “command not found” or “not recognized”, see Troubleshooting below.

Step 2: Create a project folder for the course

Keep all your course notebooks, data, and the requirements.txt file (the list of packages the course uses) together in one folder. Download requirements.txt from the course repository and save it into this folder.

macOS:

mkdir -p ~/Documents/LS100
cd ~/Documents/LS100

Windows:

mkdir $HOME\Documents\LS100
cd $HOME\Documents\LS100

The cd (“change directory”) command moves your terminal into the folder. Every command from here on runs inside this folder.

Step 3: Create a virtual environment

macOS:

python3 -m venv .venv

Windows:

python -m venv .venv

This creates a folder called .venv inside your project folder. It holds a private copy of Python and every package you install for this course.

Reading the command piece by piece. Nothing here is magic. Each part of the command has a plain meaning:

Why is it called .venv? You could call it anything (see below), but .venv is the name most Python users choose, for three reasons:

Using a different name. Any folder name works. For example, to call your environment ls100-env:

macOS:

python3 -m venv ls100-env

Windows:

python -m venv ls100-env

If you choose your own name, replace .venv with it in every later command in this section (activation, the “Coming back later” table, and troubleshooting). For example, you’d activate with source ls100-env/bin/activate on macOS or ls100-env\Scripts\Activate.ps1 on Windows, and your prompt would then start with (ls100-env). Avoid spaces in the name, because they make commands awkward to type. And without a leading dot, the folder will be visible in Finder like any other folder.

What’s inside the folder? If you open it, you’ll find ordinary files and folders:

Because it’s just a folder, deleting it removes the environment completely, and you can always recreate it with the steps above.

Step 4: Activate the virtual environment

macOS:

source .venv/bin/activate

Windows:

.venv\Scripts\Activate.ps1

Your prompt now starts with (.venv), which tells you the environment is active. From this point on, the command is simply python on both macOS and Windows.

Reading the command piece by piece.

What activation actually does. When you type a command like python, your terminal doesn’t magically know where that program lives. It checks a list of folders, one by one and in order, and runs the first program it finds with that name. This list is called the PATH. Activation changes three things in your current terminal window:

  1. It puts the environment’s folder at the front of the PATH. That’s .venv/bin on macOS or .venv\Scripts on Windows. That folder contains the environment’s own python and pip, so typing python now finds that copy first. This is also why python works on both macOS and Windows once the environment is active, and why commands you install later (like jupyter) are found only while it is active.

  2. It records where the environment is in a setting called VIRTUAL_ENV, which some tools read to find the active environment.

  3. It adds (.venv) to your prompt as a reminder.

That’s all. Activation doesn’t install anything, and it doesn’t change your main Python installation or any other terminal window. It lasts only as long as this terminal window is open, which is why the “Coming back later” steps include activating again.

See it for yourself. Ask the terminal which python it will run:

macOS:

which python

Windows:

Get-Command python

You should see a path that ends inside your project folder, such as .../Documents/LS100/.venv/bin/python on macOS or ...\Documents\LS100\.venv\Scripts\python.exe on Windows. You can also ask Python itself where it’s running from:

python -c "import sys; print(sys.prefix)"

This prints the path of your .venv folder. Try the same commands in a new terminal window without activating, and you’ll see your main Python installation instead.

Turning it off. Type deactivate to undo the three changes above and return the terminal to normal, or simply close the window.

Step 5: Install the course packages

python -m pip install --upgrade pip
python -m pip install -r requirements.txt

This installs Jupyter along with everything the course notebooks use (pandas, matplotlib, OpenCV, MediaPipe, PyTorch, and more). It is a large download (a few GB, mostly PyTorch), so expect it to take several minutes.

Step 6: Launch Jupyter Notebook

jupyter notebook

A browser tab opens at http://localhost:8888 showing the files in your project folder. Click any .ipynb file to open it, or choose New > Notebook to create one. Keep the terminal window open while you work: it is running the Jupyter server. When you’re done, save your notebooks, close the browser tab, and press Ctrl + C in the terminal to stop Jupyter.

Coming back later

You don’t repeat the setup. Each time you want to work, open a new terminal and run:

macOSWindows
1. Go to your foldercd ~/Documents/LS100cd $HOME\Documents\LS100
2. Activate the environmentsource .venv/bin/activate.venv\Scripts\Activate.ps1
3. Start Jupyterjupyter notebookjupyter notebook

Optional: Run notebooks in VS Code

If you prefer VS Code to the browser, you can open the same notebooks there:

  1. Install the Python and Jupyter extensions (Extensions panel, left sidebar).

  2. Choose File > Open Folder… and open your LS100 folder.

  3. Open any .ipynb file, click Select Kernel (top right), and pick the environment that lists .venv.

VS Code then runs your notebook cells using the course environment, so you don’t need to start jupyter notebook yourself.

Anaconda users

Anaconda already includes Jupyter. You can launch it from Anaconda Navigator, but for this course it’s still best to create a separate environment for the course packages. Open Terminal (macOS) or Anaconda Prompt (Windows), go to your project folder, and run:

conda create -n ls100 python=3.11
conda activate ls100
python -m pip install -r requirements.txt
jupyter notebook

Next time, you only need conda activate ls100 followed by jupyter notebook.

Troubleshooting

Now that your environment is set up and you know how to run Python, let’s start our first exploration with Python.

Hands-On Practice: Using a Jupyter Notebook to Explore Python

At this point, you have Python set up and know the basic concepts. Now, it is time to play with code in a Jupyter Notebook. Please visit the module 00B on the course website and start practicing Python with the notebooks in numeric order. You can either use an online notebook environments like Google Colab or run the notebook locally using the Local setup steps above.

Conclusion: From Basics to Building Full Pipelines

Congratulations on making it through this introduction to Python! You’ve learned what Python is, set up an environment, and covered fundamental programming concepts from variables and functions to loops and classes. At this stage, you should be able to write simple programs and use notebooks to experiment with code. You even saw how to bring in external libraries to work with real-world data like audio and video.

Learning programming is a bit like learning a language – at first, you learn words and grammar (we covered the “words” like variables, and “grammar” like syntax/loops/functions). The next step is to practice by actually “speaking” – writing programs to solve problems or automate tasks. Start with small projects or exercises: for example, write a program to convert units (temperature, currency), or a simple number guessing game, or analyze a small dataset.

As you become comfortable with the basics, you can explore more advanced topics or domains:

Keep in mind that Python was created to be an easy-to-understand language, and it has a very supportive community. There are countless resources and forums (like Stack Overflow, Reddit’s r/learnpython, etc.) where you can seek help and advice.

With the guide and the hands-on practice in the notebook, you’re well on your way. Happy coding, and welcome to the world of Python programming! As you continue, you’ll discover more cool reasons to learn and use Python, including the ability to quickly turn ideas into working code. All the best for your journey to using Python for your research. Python’s versatility and power will be your ally every step of the way. Enjoy!