Python is a free, open-source, powerful programming language widely used by developers. PIP, also known as a “Preferred Installer Program,” is a package manager used for installing and managing additional Python packages via the command line. PIP makes your job easier by managing full lists of packages and corresponding version numbers. PIP is a package manager that connects to the Python Package Index and allows users to install user-defined projects locally with the use of a setup.py file.
In this post, we will explain how to install and use PIP on Arch Linux.
Prerequisites
- A fresh Arch Linux server on the Atlantic.Net Cloud Platform
- A root password configured on your server
Step 1 – Create Atlantic.Net Cloud Server
First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Arch Linux as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.
Step 2 – Configure Repository
By default, the default repository is outdated in Arch Linux, so you will need to modify the default mirror list. You can do it by editing the mirrorlist configuration file:
nano /etc/pacman.d/mirrorlist
Remove all lines and add the following lines:
## Score: 0.7, United States Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch ## Score: 0.8, United States Server = http://lug.mtu.edu/archlinux/$repo/os/$arch Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch ## Score: 0.9, United Kingdom Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch ## Score: 1.5, United Kingdom Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch ## Score: 6.6, United States Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch ## Score: 6.7, United States Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch ## Score: 6.8, United States Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch ## Score: 7.1, India Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch ## Score: 10.1, United States Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch
Save and close the file, then update all the package indexes with the following command:
pacman -Syu
Step 2 – Install PIP on Arch Linux
Before installing PIP, Python must be installed on your server. If not installed, you can install it by running the following command:
pacman -S python
After the installation, you can verify the Python version using the following command:
python --version
You should get the following output:
Python 3.10.8
Next, install PIP using the following command:
pacman -S python-pip
Once PIP is installed, you can verify the installed version of PIP using the following command:
pip3 --version
You should see the following output:
pip 22.2.2 from /usr/lib/python3.10/site-packages/pip (python 3.10)
Step 3 – How to Update PIP
It is a good idea to update PIP to the latest version. You can update it using the following command:
pip3 install --upgrade pip
You should see the following output:
Requirement already satisfied: pip in /usr/lib/python3.10/site-packages (22.2.2)
You can now verify the PIP version again using the following command:
pip3 --version
You should see the following output:
pip 22.2.2 from /usr/lib/python3.10/site-packages/pip (python 3.10)
Step 4 – How to Use PIP
You can use the –help option to see a list of all important options available with PIP:
pip3 --help
You should see the following output:
Usage: pip3[options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. check Verify installed packages have compatible dependencies. config Manage local and global configuration. search Search PyPI for packages. cache Inspect and manage pip's wheel cache. wheel Build wheels from your requirements. hash Compute hashes of package archives. completion A helper command used for command completion. debug Show information useful for debugging. help Show help for commands.
To install a specific package, run the following command:
pip3 install wheel
To get detailed information about the installed package, run the following command:
pip3 show wheel
You will get the following output:
Name: wheel Version: 0.37.1 Summary: A built-package format for Python Home-page: https://github.com/pypa/wheel Author: Daniel Holth Author-email: [email protected] License: MIT Location: /usr/lib/python3.10/site-packages Requires: Required-by:
To get a list of all installed packages, run the following command:
pip3 list
You should see the following output:
Package Version ------- ------- pip 22.2.2 wheel 0.37.1
To get a list of all outdated packages, run the following command:
pip3 list --outdated
To uninstall a specific package from your system, run the following command:
pip3 uninstall wheel
You will get the following output:
Found existing installation: wheel 0.37.1 Uninstalling wheel-0.37.1: Would remove: /usr/bin/wheel /usr/lib/python3.10/site-packages/wheel-0.37.1.dist-info/* /usr/lib/python3.10/site-packages/wheel/* Proceed (Y/n)? y Successfully uninstalled wheel-0.37.1
Conclusion
In the above post, you learned how to install and use the PIP package manager on Arch Linux. You also learned how to manage Python packages with PIP. You can now use the PIP in to manage the Python dependencies. Try it on a dedicated server hosting from Atlantic.Net!