Skip to main content

How to update your Python libraries on Linux, macOS, and Windows

· 2 min read

Quick tutorial on how to get your libraries up to speed.

Checking Installed Python Libraries

Keeping your Python libraries up to date is crucial for security, performance, and access to the latest features. Whether you're using Windows, Linux, or macOS, updating your Python libraries is a straightforward process. In this guide, we'll walk you through the steps for each operating system.

Before updating, you can check which libraries are installed and their versions by running this command on your command terminal:

pip list --outdated

This command displays a list of installed packages that have newer versions available.

Updating Python libraries on Linux

Using the Terminal:

  1. Open the Terminal window:

  2. To update a specific package:

pip install --upgrade package_name

  1. To update all outdated packages:

pip list --outdated --format=freeze | cut -d= -f1 | xargs -n1 pip install --upgrade

If you are working on a virtual environment, make sure to activate it first and then proceed with the same process.

Updating Python libraries on macOS

Using the Terminal:

  1. Open the Terminal

  2. To update a specific package:

pip install --upgrade package_name

  1. To update all outdated packages:

pip list --outdated --format=freeze | cut -d= -f1 | xargs -n1 pip install --upgrade

If you installed Python via Homebrew, ensure that it's also updated using:

brew upgrade python

Then you'll also need to ensure pip is also updated by using:

pip install --upgrade pip

Updating Python libraries on Windows

Using Command Prompt or PowerShell

  1. Open Command Prompt (cmd) or PowerShell.

  2. Use the following command to update a specific package (Replace package_name with the actual library name):

pip install --upgrade package_name

  1. To update all outdated packages at once, run:

pip list --outdated --format=freeze | ForEach-Object {($_ -split '=')[0]} | ForEach-Object {pip install --upgrade $_}

If you are working in a virtual environment, make sure to activate it first, then follow the same update process.