Are you trying to install packages and libraries with pip, but pip is not installing libraries and saying pip command not found? 🤔 Then keep reading; this article will help you fix the PIP install and uninstall not working error so you can download and install libraries and packages more quickly.
Python is a general-purpose, widely used high-level programming language that lets you work efficiently in integration systems. One of the good things about Python is that it allows you to easily download and install libraries and packages with the pip command.
But what is the pip command? Let’s learn about it in detail and what you can do to fix issues when the pip installs and uninstall authorities are not working correctly.
Table of Contents
What is a PIP Command in Python?
In Python, pip is a package management system to install, manage, and uninstall software libraries and packages. These files are stored in an online repository named PyPi, which stands for Python Package Index. PIP uses PyPi as a default source to download libraries, packages, and dependencies.
The basic syntax of the pip command is as follows:
# install a package pip install package_name # uninstall a package pip uninstall package_name
Essentially, how it works is PIP will go to the online python packages repository, PyPi, and look for the package name. If it finds that package, it will download it; otherwise, it will display an error like the following:
But before using pip, it is mandatory first to install pip itself and then use it accordingly; otherwise, you will be facing the pip command not found and pip not installing libraries errors.
So let’s see how to install pip in Python.
How to Install PIP for Python?
Before installing pip, it is mandatory to install Python, and if you have already installed it, you can verify if it was successfully installed using the below command:
By now, Python should be installed on your system and working perfectly. Now it’s time to install pip, but it is installed by default during python installation, and in case it isn’t there, you have to download it manually.
Download And Install PIP using CURL in Python
Curl is a UNIX command that sends GET, PUT, and POST requests to a URL. This tool is utilized for downloading files, testing REST APIs, etc. In Python, a curl is a tool for transferring data requests to and from a server.
To do so, use the following commands:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python get-pip.py
The above commands should have installed pip into your local machine, and to verify that it’s working, you can use the below command:
# find the version of pip pip --version
Perfect!👌 We have successfully installed the pip, which should be working fine. Furthermore, you may want to update it to use this command.
If you are still facing issues with the pip command and it isn’t working, then probably you should use pip3 instead of pip. The pip3 relates to Python3, whereas a simple pip can also install packages and libraries, but in some cases, it isn’t capable of doing so, and there you should use pip3.
How to Update PIP?
Technology is continuously updating and improving, but the software is changing faster. Hence it is essential to keep yourself updated and be synchronized with the systems.
Similarly, Python and pip developers always try to improve the current versions by adding more functionalities or updating the current ones. So if you are facing issues downloading some packages, you can first upgrade your pip version and then try it.
python -m pip install --upgrade pip
This will update your pip to the latest version of it.
How to Install a Package Using the PIP Command?
Until now, I assume you have successfully installed Python and set up pip on your local machine to download and install packages and libraries.
Perfect! Now you are ready to download and install packages using the pip command to do so, and you will need to follow the syntax of the pip command.
# goto PyPI --> find the package ok --> download and install it pip install ok
Congratulations 👏! You have successfully installed the ok package and can import it into your python program.
Here’s a quick note to remember before starting any troubleshooting when the pip command isn’t working, you can try out using pip3 instead.
How to Uninstall a Package Using the PIP Command?
The uninstallation process is similar to any package or library installation using the pip command. Still, the only change is to uninstall instead of install in the pip command.
Let’s see an example of uninstalling a package using the PIP command.
# uninstall the 'ok' package from your local machine pip uninstall ok
See, when you run the above command using the command line interface (CLI), it will ask you for confirmation whether to delete the package or not. And upon allowing it to uninstall the box, it has successfully uninstalled it.
To summarize the article, we have discussed what pip is, how to install it on your local machine, and to install and uninstall different packages. In Python, pip is a powerful and helpful command allowing you to import packages, libraries, and their dependencies easily.
A quick recap of the topics we have covered in the article
- What is the pip command in Python?
- How to install the pip command in Python?
- Downloading and installing pip using CURL in Python
- How to install a package using the pip command?
- How do you uninstall a package using the pip Command?
A quick question to all the readers, how the pip command has made development easy for you?