How to Install pip3 on Amazon Linux 2

Amazon Linux 2 is an excellent choice for work with AWS. However, some users might find it challenging when trying to install certain components, like pip3. This post will guide you through the process of installing pip3 on Amazon Linux 2.

How to Install pip3 on Amazon Linux 2

Amazon Linux 2 is an excellent choice for work with AWS. However, some users might find it challenging when trying to install certain components, like pip3. This post will guide you through the process of installing pip3 on Amazon Linux 2.

The Python Package Installer, pip, is a standard package-management system. It allows you to install and manage additional libraries and dependencies that are not distributed as part of the standard library. pip3 refers to the Python3 version of pip.

Step 1: Update the System

As a good practice, we should always update the system before installing a new package:

sudo yum update -y

Step 2: Install Python3

The next step is to install Python3 using yum. Amazon Linux 2 repositories have Python 3.7 available:

sudo yum install python3 -y

After installation, you can check the Python version running:

python3 --version

The output should display the installed version of Python3.

Step 3: Install pip3

Now it’s time to install pip3. Use the following command to install:

sudo yum install python3-pip -y

You can validate the installation of pip3 by checking its version:

pip3 --version

The output should show the installed version of pip3.

Troubleshooting: Python3 and pip3 not Found

If you receive a “not found” error for Python3 or pip3, it’s likely because the system does not know where to find the Python3 or pip3 executables.

You can fix this by creating a symbolic link to the executables:

sudo ln -s /usr/bin/python3 /usr/bin/python
sudo ln -s /usr/bin/pip3 /usr/bin/pip

Now, check the versions again:

python --version
pip --version

Step 4: Upgrading pip3

To ensure you have the latest version of pip3, you can upgrade pip3 using itself:

pip3 install --upgrade pip

This will upgrade pip3 to the latest version.

Conclusion

Installing pip3 on Amazon Linux 2 is straightforward with yum. This guide provided the steps to install pip3 and troubleshoot potential issues.

Remember to regularly update your system and the packages you have installed. You can do this for all Python packages using the command:

pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U

This command lists all installed Python packages, checks if they are outdated, and if they are, upgrades them.

By understanding how to install and manage pip3 on Amazon Linux 2, you’ll be better equipped to handle your Python development needs on AWS.

Keywords: Python, pip3, Amazon Linux 2, AWS, package management, installation guide, troubleshooting, system update, Python3, package upgrade.


About Saturn Cloud

Saturn Cloud is your all-in-one solution for data science & ML development, deployment, and data pipelines in the cloud. Spin up a notebook with 4TB of RAM, add a GPU, connect to a distributed cluster of workers, and more. Join today and get 150 hours of free compute per month.