Pip is a popular tool used to install and manage Python packages. Most of its users are happy with its capabilities of handling binary packages over the easy_installed packages manager, as Pip allows 3rd party package installations. Mostly, Python comes with Pip as a default, but in this tutorial, we will show how to install and check the Pip version as well as some commands for using Pip on Ubuntu 16.04.
Frontline :
All these instructions are specific for an Ubuntu 16.04 LTS server, where we are logged in as root.
# Steps to install and verify Pip
1) First of all, we have to ensure that all packages are up-to-date. Run the following command and you will get an output of any package getting their update.
apt-get update
2) Now, install Pip with cURL and Python. Downloading with cURL command shows the latest version of Pip.
curl “https://bootstrap.pypa.io/get-pip.py” -o “get-pip.py”
python get-pip.py
3) The next step is to verify the installation of Pip.
pip --version
It gives the output as :
pip --version pip 18.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
This way you can install and verify Pip.
Now, let’s learn some basic Pip commands.
To install Libraries
Using the following commands, Pip can install 3rd party packages like Django, Tensorflow, Numpy, Pandas, etc.
pip install <library_name>
To search for Libraries
Using command lines you can also search for other libraries in Python repository. For example, we are taking Django packages, so the search command will show a similar list as shown below :
pip search django
django-bagou (0.1.0) - Django Websocket for Django django-maro (0.0.2) - `django-maro` is utility for django. django-hooked (0.1.7) - WebHooks for Django and Django Rest Framework. django-ide (0.0.5) - A Django app to develop Django apps django-mailwhimp (0.1) - django-mailwhimp integrates mailchimp into Django django-six (1.0.4) - Django-six —— Django Compatibility Library django-umanage (1.1.1) - Django user management app for django django-nadmin (0.1.0) - django nadmin support django version 1.8 based on django-xadmin diy-django (1.3.1) - diy-django
To uninstall a library
In case you don’t need a library then you can uninstall easily using the following command :
pip uninstall
To install Python resources
Many times, Python packages have requirements.txt file, incase you see this file, then you can run the following command to install all libraries in that package.
pip install -r requirements.txt
Also Read :
1) How to Install Node.js on Ubuntu 16.04
2) A Guide to Install and Configure Mod_Security on Ubuntu 16.04 Server