If you’re working with Python 3 on your server environment, chances are you’ll need to install third-party modules to extend its functionality. Whether you’re building web applications, automating tasks, or working with data, Python’s vast ecosystem of packages has you covered. The go-to tool for installing these modules is pip3.

In this article, we’ll guide you through using pip3 effectively, from installation to common use cases and troubleshooting tips.

What Is pip3?

pip3 is the package installer for Python 3. It allows you to download and install Python packages from the Python Package Index (PyPI) and other indexes. It is the Python 3-compatible version of pip, and it typically corresponds to the python3 command on most systems.

Installing pip3

Linux (Debian/Ubuntu):

sudo apt update
sudo apt install python3-pip

macOS (with Homebrew):

brew install python3

Homebrew installs both python3 and pip3.

Windows:

If you download and install Python 3 from the official site (https://www.python.org/), make sure to check “Add Python to PATH” during installation. pip3 will be installed automatically alongside Python 3.

To verify installation:

pip3 --version

Basic Usage

To install a Python package:

pip3 install package_name

Examples:

  • Install requests:

    pip3 install requests
  • Install a specific version:

    pip3 install numpy==1.21.0
  • Upgrade a package:

    pip3 install --upgrade pandas
  • Install multiple packages from a file:

    pip3 install -r requirements.txt

Installing Packages for a Specific Project

It’s a best practice to use virtual environments to avoid conflicts between project dependencies.

Create and activate a virtual environment:

python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate

Then use pip3 as usual:

pip3 install flask

Uninstalling Packages

To remove a package:

pip3 uninstall package_name

Common Issues & Troubleshooting

  • Permission errors: Use --user to install packages only for your user:

    pip3 install --user package_name
  • Command not found: If pip3 is not found, try reinstalling Python 3 or use:

    python3 -m pip install package_name
  • Conflicting dependencies: Tools like pip-tools or pipdeptree can help manage dependencies more cleanly.Final Thoughts

Using pip3 is an essential part of working with Python 3. Whether you’re a beginner or a seasoned developer, understanding how to install and manage Python modules ensures your projects run smoothly and stay up to date. Combine it with virtual environments for best results, and you’re ready to dive into the Python ecosystem.