![]() |
Python has been preferred over all programming languages for technological advancement. It is one of the most lucrative programming languages that is used as the main programming language by more than 80%of developers. It is used for web development, mobile applications, hardware programming, and many more. Pip commands cannot be ignored when we talk about Python. When you get your task done within a second, it feels great, Right! Here comes the role of pip commands in Python which allow users to perform certain operations in a second. Pip is a package management system that is used to manage software packages, it also comes pre-installed with Python. There are certain commands which you should be handy and keep in practice whether you build a small or big application. Let’s discuss those. Here, we present 11 Pip commands for Python Developers:1. Install and Uninstall PackageTo install and uninstall a certain package as per your requirement, this command plays a major role. You can directly install or uninstall using this command in your command prompt by going into the Python folder.
Here, package_name can be any package, whether it is Pandas, NumPy, etc.
2. Update PipYou can also update the pip if it’s not in its updated version. You just need to type pip –version to check whether it has an updated version or not, if not, just update it using the below-given command. Do check this command should be written under the Python folder.
3. Upgrade PackageOnce, you see the installed packages are outdated, upgrade them using the command pip install package_name –upgrade. Also, keep in mind that this might even have compatibility issues with other packages.
4. Update All PackagesTo update all packages at once, you need to initially generate a requirements.txt file using the command pip freeze > requirements.txt, this file contains all the packages, and to update all packages you just need to update the requirements.txt file. In the list of packages in the requirements.txt file, packages with updated versions will be ignored rest will be updated.
5. Info About an Installed PackageTo know about the package’s detail like its version, and features, one must type the command pip show package_name, where package_name could be anything like Pandas, matplotlib, etc. Note: In case you don’t have a package installed in your system and you try to update it, it shows an error as “Package Not Found”.
6. Install Editable ModeOnce you install a package and you want to develop it locally, you can install it in its editable mode. It links the package to the specified location which allows you to make changes that will be reflected directly. This command pip install -e gives you the package in develop mode/ editable mode.
7. Generate Requirements.txt FileTo merge all your packages in a single file, we generate a requirements.txt file. It helps all the developers to use the package at a time. Using the command, pip freeze > requirements.txt, a requirements.txt file is generated which stores all the required packages.
8. List All Installed PackagesThis command helps you to display all the packages installed in your system. It shows a list of packages along with their version and path. Note: Only the packages installed in your system will be displayed here, not those which are installed remotely.
9. Remove All Packages Installed By PipInstead of removing packages one by one, you can directly remove all packages installed by pip to save time using the command pip freeze > requirements.txt && pip uninstall -e requirements.txt -y. Here, it creates a requirements.txt file that contains a list of packages and then uninstalls all of them.
10. Verify That Installed Packages Have Compatible DependenciesThis command checks whether all installed packages in the requirements.txt file have compatible dependencies. It checks all three conditions i.e., whether dependencies are compatible, whether the package has an updated version or not, and whether a package is missing.
11. Install All Dependencies From the requirements.txt FileAll the dependencies which are required for the project implementation can be installed using this command, pip install -r requirements.txt. Dependencies contain all the information about the package.
|
Reffered: https://www.geeksforgeeks.org
GBlog |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |