Knowledge Base Hub

Browse through our helpful how-to guides to get the fastest solutions to your technical issues.

Home  >  Web Hosting FAQ  >  Installing PIP on Ubuntu 18.04
Top Scroll

Installing PIP on Ubuntu 18.04

 6 min

This article includes steps to install PIP on Ubuntu 18.04.

Prerequisite :

Commands mentioned in this article are for Ubuntu 18.04 LTS server. We have logged in as a root user.

First of all, we need t to verify that the Python is installed :

Run the following command, to verify that Python is installed on your server :

root@host:~# python

Python 3.6.8 (default, Jan 14 2019, 11:02:34)

[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>>

This command checks the Python version and also verifies if Python 3 is installed on your Ubuntu system.

Type Ctrl+C to exit the Python shell.

# Install PIP

Start updating Ubuntu

root@host:~# apt update
root@host:~# python3 --version

Python 3.7.5

Then, install PIP.

root@host:~# apt install python3-pip

... 

...

...

After this operation, 129 MB of additional disk space will be used.

Do you want to continue? [Y/n] Y

...

...

...

Setting up python3.6-dev (3.6.8-1~18.04.3) ...

Setting up libpython3-dev:amd64 (3.6.7-1~18.04) ...

Setting up build-essential (12.4ubuntu1) ...

Setting up python3-dev (3.6.7-1~18.04) ...

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Processing triggers for libc-bin (2.27-3ubuntu1) ...

root@host:~#

Now, check the version of your installed PIP, using the following command.

root@host:~# pip3 --version

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

#Using cases

We have several options to use PIP.

Either we can stay within a virtual environment and test our programs within a distinct or virtual Python environment. Or, we can also run PIP globally, this can make a program to run on the server itself.

In this example, we are going to work on our projects within the virtual Python environment (by using venv) so that it will limit the interaction with other projects for their dependencies. Additionally, it will also avoid a huge conflict that can take place with the system’s default Python environment. We run the following code, to display all the available options for PIP :

root@host:~# pip3 --help

Usage:

    pip3 <command> [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.

                  search              Search PyPI for packages.

                 wheel                 Build wheels from your requirements.

                 hash                   Compute hashes of package archives.

                completion        A helper command used for command completion.

                 help                    Show help for commands.

General Options:

               -h, --help              Show help.

               --isolated              Run pip in an isolated mode, ignoring environment variables and user configuration.

                -v, --verbose        Give more output.  Option is additive, and can be used up to 3 times.

             -V, --version          Show version and exit.

             -q, --quiet               Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).

           --log <path>              Path to a verbose appending log.

          --proxy <proxy>        Specify a proxy in the form [user:passwd@]proxy.server:port.

       --retries <retries>        Maximum number of retries each connection should attempt (default 5 times).

       --timeout <sec>            Set the socket timeout (default 15 seconds).

       --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.

       --trusted-host <hostname>      Mark this host as trusted, even though it does not have valid or any HTTPS.

       --cert <path>                        Path to alternate CA bundle.

       --client-cert <path>           Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.

      --cache-dir <dir>                 Store the cache data in <dir>.

       --no-cache-dir                     Disable the cache.

--disable-pip-version-check 
                                                     Don't periodically check PyPI to determine whether a new version of pip is available for download. 
                                                   Implied with --no-index.

Use pip –help to get more information about a specific PIP.

As an example, to get more information about the install command, type following command :

root@host:~# pip3 install --help

Use the following command, to search for a specific package :

root@host:~# pip3 search <search_string>

root@host:~# pip3 search pypi

go-pypi (0.0.4)                      - Go pypi

pypi-api (0)                          - pypi-api

upt-pypi (0.5)                     - PyPI frontend for upt

pypi-chat (0.0.4)                - A project of pypi chat.

pypi-xmlrpc (2019.4.13)     - pypi XML-RPC

Flask-Pypi-Proxy (0.5.1)     - A Pypi proxy

pypi-task-demo (0.0.1)       - PyPI demo

pypi-test-fiveplus (0.0.2)   - PyPI Test

hello-pypi-yue (0.1.1)          - The Pypi test

aeverall-testing-pypi (0.1)    - Test of PyPI

Use the following command, to see all the installed packages :

pip3 search installed package

Usually, the output shows a significant number of packages.

Use the following command, to install a package using PIP :

pip3 install <package_name>

Run following command, to uninstall a package using PIP :

pip3 uninstall <installed_package_name>

That’s it.

Also Read :

1) Installing Pip on Ubuntu 16.04 LTS

2) How to List and Filter Users in Linux

For our Knowledge Base visitors only
Get 10% OFF on Hosting
Special Offer!
30
MINS
59
SECS
Claim the discount before it’s too late. Use the coupon code:
STORYSAVER
Note: Copy the coupon code and apply it on checkout.