<\/span><\/h2>\n\n\n\nFirst, you need to login to your Ubuntu 20.04 VPS via SSH as the root user account, or as a user with sudo privileges:<\/p>\n\n\n\n
ssh root@Server_IP_Address -p Port_Number<\/pre>\n\n\n\nOf course, you will need to replace Server_IP_Address<\/code> and Port_Number<\/code> with your actual server IP address and SSH port number.<\/p>\n\n\n\nBy running the following command, all installed packages will be updated and upgraded:<\/p>\n\n\n\n
apt update && apt upgrade -y<\/pre>\n\n\n\nYou can also restart your server to ensure that all of the latest configuration files get read and used.<\/p>\n\n\n\n <\/figure>\n\n\n\n<\/span>Install pip for Python 3<\/span><\/h2>\n\n\n\nWe assume that you already have the default Python version installed on your server. To check if Python 3 is already installed on your server, use the command below:<\/p>\n\n\n\n
python3 -V<\/pre>\n\n\n\nYou should get the following output:<\/p>\n\n\n\n
root@ubuntu20:~# python3 -V\nPython 3.8.2<\/pre>\n\n\n\nBefore proceeding with the installation of pip, it is a good idea to confirm whether pip is already installed on your server. You can do this with the command:<\/p>\n\n\n\n
pip3 -V<\/pre>\n\n\n\nIf you get the following output:<\/p>\n\n\n\n
Command 'pip3' not found<\/pre>\n\n\n\nThis means that pip3 is not installed on your server. You can install pip3 by executing this next command:<\/p>\n\n\n\n
apt install python3-pip<\/pre>\n\n\n\nBy executing the above command, all of the dependencies required for pip will be installed along with PiP. When the installation is complete, you can validate the installed pip with the command:<\/p>\n\n\n\n
pip3 --version<\/pre>\n\n\n\nYou should have an output similar to the following:<\/p>\n\n\n\n
root@ubuntu20:~# pip3 -V\npip 20.0.2 from \/usr\/lib\/python3\/dist-packages\/pip (python 3.8)<\/pre>\n\n\n\n<\/span>Install PiP for Python 2 (optional)<\/span><\/h2>\n\n\n\nIf for some reason you want to use Python 2 instead of the default Python 3 version, you can follow this section of the article.<\/p>\n\n\n\n
To install Python 2 you can run the command:<\/p>\n\n\n\n
apt install python2<\/pre>\n\n\n\n <\/figure><\/div>\n\n\n\nSince PiP for Python2 is not available in the Ubuntu 20.04 repository, in this step we will use the get-pip.py<\/code> script. Use the following command to download the get-pip.py<\/code> script:<\/p>\n\n\n\n<\/p>\n\n\n\n
curl https:\/\/bootstrap.pypa.io\/get-pip.py --output get-pip.py<\/pre>\n\n\n\nNow you can execute the script with python2 to install pip for Python 2.<\/p>\n\n\n\n
python2 get-pip.py<\/pre>\n\n\n\nOnce the installation is complete, you can verify the pip version with:<\/p>\n\n\n\n
pip -V<\/pre>\n\n\n\nIf you get the following output:<\/p>\n\n\n\n
root@ubuntu20:~# pip -V\npip 20.1.1 from \/usr\/local\/lib\/python2.7\/dist-packages\/pip (python 2.7)<\/pre>\n\n\n\nThen you have the correct version of pip installed for Python 2.<\/p>\n\n\n\n
<\/span>How to Use pip3<\/span><\/h2>\n\n\n\nIn this step of the article, we will show you a few useful basic pip commands. Now that pip is installed, you can try to use it.<\/p>\n\n\n\n
The basic syntax for pip3 is the following:<\/p>\n\n\n\n
pip3 <command> [options]<\/pre>\n\n\n\nThe following examples are the most commonly used pip3 commands.<\/p>\n\n\n\n
If you want to install a package:<\/p>\n\n\n\n
pip3 install package_name<\/pre>\n\n\n\nYou can list all installed packages:<\/p>\n\n\n\n
pip3 list<\/pre>\n\n\n\nOr you can search for a package:<\/p>\n\n\n\n
pip3 search package_name<\/pre>\n\n\n\nIf for some reason you want to remove\/uninstall some package, you can use the command:<\/p>\n\n\n\n
pip3 uninstall package_name<\/pre>\n\n\n\nYou can find more options and usage examples by running the help command:<\/p>\n\n\n\n
pip3 --help<\/pre>\n\n\n\nOutput:<\/p>\n\n\n\n
Usage:\n pip3 <command> [options]\n\nCommands:\n install Install packages.\n download Download packages.\n uninstall Uninstall packages.\n freeze Output installed packages in requirements format.\n list List installed packages.\n show Show information about installed packages.\n check Verify installed packages have compatible dependencies.\n config Manage local and global configuration.\n search Search PyPI for packages.\n wheel Build wheels from your requirements.\n hash Compute hashes of package archives.\n completion A helper command used for command completion.\n debug Show information useful for debugging.\n help Show help for commands.\n\nGeneral Options:\n -h, --help Show help.\n --isolated Run pip in an isolated mode, ignoring environment variables and user configuration.\n -v, --verbose Give more output. Option is additive, and can be used up to 3 times.\n -V, --version Show version and exit.\n -q, --quiet Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).\n --log Path to a verbose appending log.\n --proxy Specify a proxy in the form [user:passwd@]proxy.server:port.\n --retries Maximum number of retries each connection should attempt (default 5 times).\n --timeout Set the socket timeout (default 15 seconds).\n --exists-action Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.\n --trusted-host Mark this host or host:port pair as trusted, even though it does not have valid or any HTTPS.\n --cert Path to alternate CA bundle.\n --client-cert Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.\n --cache-dir\n Store the cache data in. \n --no-cache-dir Disable the cache. --disable-pip-version-check\n --disable-pip-version-check\n Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.\n --no-color Suppress colored output\n --no-python-version-warning\n Silence deprecation warnings for upcoming unsupported Pythons.\n<\/pre>\n\n\n\nAnd if you are interested in some specific command details, you can use the following command:<\/p>\n\n\n\n
pip3 <command> --help<\/pre>\n\n\n\nCongratulations! You have successfully installed pip on ubuntu 20.04, and learned a few basic commands for pip.<\/p>\n\n\n\n
\n\n\n\n