Python supported a large collection of modules, packages and functions to accomplish various tasks. Some popular open-source packages are OpenCV, Pandas, Pillow, etc. We need to install these open-source packages in our Python environment to import them into a Python program. To install, uninstall and upgrade any package in Python, the “pip” is utilized.
This post provides a complete guide on uninstalling a package from Windows or Linux using the pip package manager.
Uninstall a Package in Python Using PIP (For Windows)
Follow the below steps to uninstall any Python package utilizing the pip command.
Note: Before going to the uninstallation steps, you must locate/add Python to the Windows path. For adding the path of Python to the path of Windows, you can check this dedicated article.
Step 1: Open CMD Terminal
Firstly, open the CMD terminal by pressing the (Window Key + R) button simultaneously on the keyboard. After that, type the word “cmd” and press enter:
Step 2: Uninstall Package Using PIP
To uninstall any package, you need to follow the below template:
> pip uninstall <Package_Name>
Now, we use the above template to uninstall the PIL/Pillow module in Python using pip. Here is an example:
From the above snippet, it is verified that the “Pillow” version “9.4.0” has been removed from Python.
For further verification, use the below command in the terminal:
> pip show pillow
Note: To upgrade the “pip”‘ package manager, follow the complete guide in this article.
Uninstall a Package in Python Using PIP (For Linux)
To uninstall a package in Python using pip in Linux; you need to type the following command in a terminal window:
$ pip uninstall pandas
For verification, type the below command in the terminal:
$ pip show pandas
Note: You learned the process of uninstalling a package in Python using the pip package manager. To install any package in Python using the pip, follow the guidelines provided in this blog.
Conclusion
To uninstall a package in Python using the “pip” package manager, you need to execute the “pip uninstall <package_name>” command from the CMD terminal. After the uninstallation, the “pip show <package_name>” command can be used to verify the package removal from the Python environment. This post demonstrated a thorough guide on uninstalling a package in Python using the pip package manager.