How to Install PIP on Arch Linux


If you want to use Python packages from PyPI, you need pip. With pip, you can install any Python package. But pip is not there by default on Arch Linux systems. You have to first install Python to get the pip on Arch.

We will use the default Pacman package manager to install pip on the Arch system. You can also install pip via its official installer. Let’s cover both methods in detail. We will also show you how pip can be used for managing the Python packages.

Contents:

1. How to Install PIP on Arch Linux

To install pip on Arch Linux, you must have Python installed first. After that, you can get the pip using Pacman or a pip installer. You can use pip to add more Python packages to your computer. Using pip, you can manage these Python packages from the command line.

To check if you have Python installed, run this command:

python --version

A black screen with yellow text Description automatically generated

If Python is not available, you can install it by typing:

sudo pacman -S python

As Python is now installed, next we will proceed towards the pip installation. As mentioned before, Pip is available both via Pacman and the default pip installer.

2. Install PIP via Pacman Package Manager

To install pip using the Pacman package manager, simply run this command:

sudo pacman -S python-pip

A computer screen with white text Description automatically generated

This will install pip for the latest Python version.

3. Install PIP via Official PIP Installer on Arch Linux

Another way to download and install pip is using the official pip installer. It is a Python script that downloads and installs pip for you.

To use the official PIP installer, you need to follow these steps:

First, download the get-pip.py script from here.

You can run the following command in the terminal to get the pip installer script:

wget -q https://bootstrap.pypa.io/get-pip.py

After downloading the get-pip.py file, open the folder where it is saved. Now, you can run the installer get-pip.py to begin installing pip:

python get-pip.py

This command will download and run a Python script that can install pip, setuptools, and wheel in your Python environment. Setuptools and wheel are tools that help you create and distribute Python packages.

Error: Externally Managed Environment

While installing pip for the first time, you will encounter the error: externally-managed-environment. You are getting this error because Arch Linux has a different way of managing Python packages than other Linux distributions. Arch Linux uses Pacman as its package manager, which installs Python packages system-wide and ensures that they are compatible with the rest of the system.

To resolve this error, remove the EXTERNALLY-MANAGED file. To remove this file, run:

sudo rm -rf /usr/lib/python3.11/EXTERNALLY-MANAGED

A screen shot of a computer Description automatically generated

The EXTERNALLY-MANAGED file is created by some packages that use setuptools to indicate that the Python environment is managed by the system and not by the user. Removing this file allows the system to install pip without conflicts.

After deleting the externally managed file, rerun the pip installer. This time you will see the pip will install without any error:

python get-pip.py

A screenshot of a computer program Description automatically generated

After the successful installation of the pip, add it to your system PATH. This way, you will be able to use pip on your Arch system:

export PATH=$PATH:/home/linux/.local/bin

Note: Remember to replace /home/linux/.local/bin with your system path.

The above command adds the /home/linux/.local/bin directory to the PATH environment variable. The PATH variable contains a list of directories. Inside this directory, the system will look and find the executable files whenever a command is executed. Once you add the /home/linux/.local/bin directory to the PATH, you can run pip from any location without specifying the full path.

4. Verify PIP Installation

Once the pip is installed, you can verify its installation by running the following command:

pip --version

If you have installed pip using Pacman the output will look like this:

A black screen with white text Description automatically generated

For the pip official installer, the output will be:

A screenshot of a computer program Description automatically generated

That’s it! Pip is installed on Arch Linux. Let’s see how to use pip to manage Python packages in Arch Linux.

5. How to Use PIP on Arch Linux

Using pip, one can easily manage the Python packages on the Arch system. It lets you install, upgrade, uninstall, and list them easily. Now we will cover different syntaxes of using pip in Arch Linux.

Update PIP to the Latest Version

To update your currently installed pip to the latest version, run this command:

pip install --upgrade pip

Search a Python Package

Previously, to search the Python packages using pip, the search command was used. But now the pip search command is no longer working due to unmanageable load and will be deprecated soon.

You can use online alternatives such as PyPI to search for Python packages.

Install a Python Package

For Python package installation, use the install option with the pip:

pip install numpy

To install a specific version of a package, use the == operator with the package name and the version.

For example, the below command will install version 1.26.2 of the numpy package.

pip install numpy==1.26.2

A screenshot of a computer Description automatically generated

If you want to install a package from a different index than the default PyPI, you can use the –index-url option with the pip install command.

For example, the given command will install pandas from the PyPI simple index:

pip install --index-url https://pypi.org/simple/ pandas

Install a Python Package from the Local Directory

If you want to install a package from a local directory or a remote URL, you can use the path or the URL as the argument to the pip install command.

For example, the given command will install the [my_package] from the current directory:

pip install ./my_package

List Installed Python Packages

To list all the installed Python packages, use the list command with pip. This command will display all packages you have and their versions:

pip list

A screenshot of a computer Description automatically generated

Upgrade a Python Package

To upgrade an installed Python package using pip, run this command after specifying the package name:

pip install --upgrade numpy

A screenshot of a computer Description automatically generated

Uninstall a Python Package

To uninstall the Python packages from your system, you can use this uninstall command with pip.

For example, to remove the NumPy package run:

pip uninstall numpy

A screenshot of a computer program Description automatically generated

Pip Help and Usage

Pip help command shows a list of all the commands that PIP supports:

pip help

A screenshot of a computer Description automatically generated

6. Remove PIP from Arch Linux

To remove the pip installed using Pacman, run the following command:

sudo pacman -R python-pip

A screenshot of a computer program Description automatically generated

If you have installed pip using the get-pip.py script, you can use the following command to uninstall pip and setuptools:

python -m pip uninstall pip setuptools

This will remove both the pip and setuptools packages that were installed by the get-pip.py script. You can also use the -y option to automatically confirm the uninstallation.

Conclusion

Pip is a package manager for Python, using which you can install Python packages using the console. To install pip on Arch Linux, make sure to have Python installed. After that, you can get pip using either the default pacman package manager or using the pip official installer script. Both these methods will give you the updated pip package manager. Use pip to install, upgrade, and manage all the Python packages. Read further about its usage in this article.

 

Categories