Check Installed Modules in PythonThere are many times when we are working on someone else’s system, and we have to complete our project there. It becomes more hectic when we have to install all the required modules in that system. It is actually messier when we have to start from scratch when we are in the mid-way of our project. The same also implies when someone else is working on our system for their own project. Therefore, in such times or many other instances, we wish that we already know what modules are already present in the system so that we don’t waste our precious time by using installation commands again for them. It is also helpful when we want to perform a particular action in our program, and we know we have these modules present in our system, and we can use these functions to do that particular task. In this tutorial, we are going to learn that how we can check installed Python modules in a system and get the list of all installed modules so that we don’t have to waste more time. Checking All Installed Python ModulesAs we have already discussed that why we would need to check the list of all installed Python modules in our system and how helpful it becomes when we have this list with us. Now, we will learn the ways by which we can check all the installed Python modules in our system and get a complete list of them. We can even check locally present Python modules in the system as well as the Python modules that we have installed in our system from the command terminal using the pip installer. We are going to use the following two methods in this section to check all the installed Python modules in our system and get a list of them:
Let’s understand the implementation of both the methods by using them and getting the list of all installed Python modules with them. Method 1: Check All Locally Installed Python Modules:If we only want to check all the locally installed Python modules, then it is very simple. We have to open our Python shell (Where the output displays), or we can even perform this task in the Jupyter notebook and Jupyter lab. In the Python shell (or in Jupyter notebook and Jupyter lab), we have to write the following command inside the shell: When we press the enter key after writing the above-given command, the Python shell will start loading the names of all the locally installed Python modules in our system, and we can see the following status window on our screen: As we can see, the list of all the locally installed Python modules is loading, and it will take some time for the Python shell to get the names of all locally installed Python modules. We have to wait for a while, and after that, it will display all the locally installed Python modules in our system, as we can see in the following output screen: Here, we can see the names of all the locally installed Python modules present in our system, and we can also save them for future references. Method 2: Check All Python Modules Installed:To check all the installed Python modules, we can use the following two commands with the ‘pip’:
Let’s use both commands in order to understand their implementation in a better way. (i) Using the ‘pip freeze’ Command: We have to use the ‘pip freeze’ command inside the command prompt terminal of our device. First, we have to open the command prompt terminal, and then we have to write the ‘pip command’ in it, and after that, we have to press the enter key. When we press the enter key, the pip installer will start collecting the list of all installed Python modules, and after a while, it will show us the list of all installed Python modules as following: (ii) Using the ‘pip list’ Command: If the pip installer present in our system is of 1.3 or higher versions, then we can also use this method for getting the list of all the installed Python modules. Like in the previous method, we simply have to write the ‘pip list’ command inside the command prompt terminal of our device and press the enter key. When we press the enter key, the pip installer will start collecting the list of all installed Python modules, and after a while, it will show us the list of all installed Python modules as following: Here, we have modified the ‘pip list’ command to: ‘pip list– format=column’ so that we can get the list of all the installed Python modules in our system in the column formats. ConclusionIn this tutorial, we have learned that how important it is that we have a list of all the installed modules in our system or someone’s system. Then, we have learned all the methods by which we can get the list of all the installed Python modules in the system. We learned about the different methods for locally installed Python modules and all Python modules installed in the system, and we used these methods to understand their implementation. |
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/263391.html