A Step-by-step Guide on How Install Package Installer for Python
Moreover, if you seek to install some additional dependencies or packages, you can simply install PIP. PIP uses Python Package Index for all the packages. You must be familiar with the term, package manager if you know the programming world. This tutorial will guide you to install PIP in Linux and Windows.
Let us now head towards the process of installing PIP in Linux first!
How to install PIP in Linux?
Now, Python Package Index is used by PIP as the default source for the packages. Hence, when you type,
pip install package_name
This command scans for the mentioned package in PyPI. As soon as it finds the package, it downloads and installs it. Now, it depends on which version either Python pip or Python3-pip, you’re working with.
Here are step-by-step snapshots of the whole process.
Start by typing the following command:
Sudo apt-get install python3-pip python-dev
Next up, you will see this window.
Here, the installer is simply providing the disk space.
Next, it downloads the libraries as shown below.
Now, all the files and packages start unpacking.
Lastly, the few more steps of the installation look like this.
root@ubuntu:~# pip3 install <package name>
As we have taken the example of Numpy library, just write numpy in the place of package name. Here is how:
root@ubuntu:~# pip3 install numpy
Moving on, let’s say you want to search for the availability of some packages, use this command:
root@ubuntu:~# pip3 search numpy
Next, to know all the Python packages installed in the system, follow this command:
root@ubuntu:~# pip3 list
To gain any additional information about the installed packages, use the following:
root@ubuntu:~# pip3 show numpy
Now, finally, if you wish to uninstall the packages, use this simple command:
root@ubuntu:~# pip3 uninstall numpy
That’s it! Yes, it is this simple to install PIP on Linux. Let us head towards our next segment.
How do you install PIP in Windows?
The first step is to check whether PIP is installed on your desktop or not. To check that, simply go to your command prompt, and write the following:
Now, if a response occurs, that’s a clear indication that your system already has PIP installed. If it doesn’t, then an error message appears on the screen, ‘program could not be found'.
Next up is the verification of the Python installation. PIP needs an active Python installation in the system. To confirm whether you have Python already installed or not, head on to the command prompt window and type:
In case the command goes unresponsive, and nothing shows on the screen, you need to install Python first before installing PIP.
Once you install Python, this is what your screen is going to display. Take a look:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jan 25 2019, 07:44:31) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Let us now quickly move towards the installation process of PIP on Windows.
Follow these steps to achieve your task:
- You need to download PIP get-pip.py
You have to download get-pip.py before installing PIP. Now, remember the location where you save the file as this path is required in the process later.
- Open the Windows Command Line
The next step is to open the Command prompt window. Simply follow these steps:
- Select Windows key + X
- Hit run
- Now type cmd.exe
If not these steps, then you can simply type cmd in the search bar and the command prompt will be displayed on your screen.
Additionally, there are instances where you have to run/access the prompt window as an administrator. Now, when can you encounter these situations? Sometimes, while you perform a task, you may encounter a message saying that you do not have access to some specific permissions in order to run an application or a program. In such situations, you are required to run the app as an admin.
In order to conclude that, click right on the Command Prompt and choose ‘Run as’, then select As Administrator. And you’re done!
- Install PIP
Now, open the Command Prompt, and type the cd command, and then the path where you saved the get-pip.py file. Remember?
Cross-check the file’s path as this can later cause a problem in the installation process.
Now, follow this command:
After this, the installation process begins.
Moving on, in order to display the list of your current directory, type:
- Check PIP version
If you wish to see the version of your PIP, go to the Command Prompt and type the following command:
The current version displays on the screen.
- Installation verification
As you had earlier initiated the process of installation, now you can check whether the process is successful or not.
If your installation is successful, you will encounter this message.
pip 18.0 from c:\users\administrator\appdata\local\programs\python\lib\site-packages\pip (python 3.7)
If not, kindly repeat your installation.
- How to configure?
The PIP configuration file in Windows is %HOME%\pip\pip.ini located at %APPDATA%\pip\pip.ini. Now, if you want to set the location as per your wish, use PIP_Config_File.
Moreover, if you further wish to upgrade your PIP version, you can do that. It discards the older version and installs the latest one. To accomplish this task, type the following command:
python -m pip install --upgrade pip
Moving onto the last segment, what if you want to downgrade the installed PIP version in your system? Well, you may think, why is this necessary?
Well, there are times when you install a new version and it does not work seamlessly. To sort that issue, you need to downgrade the version to revert to the previously installed version. Use this command:
python -m pip install pip==18.1
We hope that with the help of this article, you have successfully learned how to install PIP both in Linux and Windows. You can now easily manage your packages with the help of PIP. If you faced any issues during the installation process or have any questions, please leave them in the comment section below.