[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedJuly 10, 2023

How to Install Python Pip.

How To Install Python Pip

This guide explains how to install pip for Python 3 and Python 2 on Ubuntu 22.04. We will also show you the basics of installing and managing Python packages with pip.

 

Before You Begin

Python comes in two flavors; Python 2 and Python 3. Python 3 is included in the base system installation, and Python 2 can be installed from the default ubuntu repositories. Users are encouraged to use Python 3.

 

Installing pip for Python 3

Installing pip for Python 3 on Ubuntu 22.04 is a straightforward process. Run the following commands as root or sudo user in your terminal:

sudo apt updatesudo apt install python3-pip

The command above also installs all the dependencies required for building Python modules.

Once the installation is complete, verify it by checking the pip version:

pip3 --version

The version number may vary, but it will look something like this:

pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

 

Installing pip for Python 2

Pip for Python 2 is not included in the Ubuntu 22.04 repositories. We’ll be installing pip for Python 2 using the get-pip.py script.

If you already don’t have Python 2 installed on your system, install it by running:

sudo apt update sudo apt install python2

Use curl to download the get-pip.py script:

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

Run the script as sudo user using the python2 binary to install pip for Python 2:

sudo python2 get-pip.py

The command above installs pip globally. If you want to install it only for your user, run the command without sudo. The script also installs the setuptools and wheel packages that allow you to install source distributions.

Verify the installation by printing the pip version number:

pip2 --version

The output will look something like this:

pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

 

How to Use Pip

In this section, we show you a few useful basic pip commands. To get a list of all pip commands and options, type:

pip3 --help

You can get more information about a specific command using pip <command> –help . For example, to get more information about the install command, type:

pip3 install --help

 

Installing Packages with Pip

The most basic function of the pip tool is to install a package. Let’s say you want to install Numpy

To install the latest version of a package, you would run the following command:

pip3 install <package_name>

For example, to install the NumPy package, you would type:

pip3 install numpy

To install a specific version of a package, append == and the version number after the package name:

pip3 install numpy==1.18.5

Replace pip3 with pip2 if using Python 2.

 

Installing Packages with Pip using the Requirements Files

requirement.txt is a text file containing a list of pip packages with their versions required to run a specific Python project.

To install a list of requirements specified in a file, use the following command:

pip3 install -r requirements.txt

 

Listing Installed Packages

To list all the installed pip packages, use the “list” subcommand:

pip3 list

 

Upgrade a Package With Pip

To upgrade an already installed package to the latest version, enter:

pip3 install --upgrade package_name

 

Uninstalling Packages With Pip

To uninstall a package, run:

pip3 uninstall package_name

 

Conclusion

We have shown you how to install pip on your Ubuntu machine and manage Python packages using pip.

Keep reading
How to understand Data Collection in Linux Systems.
December 22, 2023

How to understand Data Collection in Linux Systems.

How to understand Data Collection in Linux Systems. Linux systems generate a wealth of information about their activities, performance, and security events. Understanding how to collect and analyze these data points is crucial for system administrators and IT professionals. In this comprehensive…

Read article
How to understand Pipes.
December 22, 2023

How to understand Pipes.

How to understand Pipes. Pipes in Linux are a powerful feature that facilitates communication between commands by allowing the output of one command to be used as the input for another. This seamless connection between processes enhances the flexibility and efficiency of command-line operations.…

Read article
How to use Emacs text editor.
December 21, 2023

How to use Emacs text editor.

How To Use Emacs Text Editor. Emacs is a powerful and extensible text editor that has been a favorite among developers and system administrators for decades. In this guide, we’ll explore the basics of using Emacs on a Linux system. Installing Emacs Most Linux distributions include Emacs in their…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00