Python Tutorial for Beginners 49 - How to use Pip and PyPI for managing Python packages

 


hey guys welcome to the next blog on Python tutorial for beginners in this blog we will talk about a special tool called Python pip so we are going to see what is Python pip and how to use Python pip so let's get started so first of all what is Python pip so pip is a command-line tool for installing and managing Python packages which are generally found on a special index called Python package index now if you want to know more about Python package index you can visit on a website called pi PI dot o-r-g PYP i dot o-r-g and you will be able to get more information about python package index on this website so what is python package index python package index or pi pi is a repository of software for python programming language now pi pi helps you to find and install software developed and shared by the Python community you can get more details about pi pi by clicking on this link or this link which are shown on the homepage of pi pi and you can see at the time of making this blog there are almost more than 150,000 project available on this index and if you want to search for any special project you can search it using this search text box so let's see how we can use Python pip using command-line so generally whenever you have installed Python on your windows or any other operating system pip will be installed with the same installation of Python so if you have installed Python 3.4 or above most probably the Python pip will be already installed on your operating system now to check which version of pip is installed on your system you can give this command Python - - version and then press Enter and it's going to show you the version of PIP installed on your system so you can see pip ten point zero point one is installed on my Windows operating system and the Python version which it supports is three point seven now the first thing which you need to know about this tool called pip is how to use this tool so to know more about this tool you can give this command Python - - help and it's going to show you the commands which you can use with this command line tool so here you can see the usage you give the PIP command and then one of these command either install download uninstall list show and all these other commands in order to install a package or an installer package or get to know more about a particular package also there are some general options here which you can read so for example if you want to get help you give these options or if you want to print the verbose output you can use these options and if you want to know the version you can use these option and all these other options are available with this command line tool which is PIP so let me clear this command prompt with the command called CLS and I'm going to first of all go into the Python shell using Python command and in here I'm going to import a special package called flask and I'm trying to see if it's already there or not so I'm going to press ENTER and it's going to show me this error which says module not found error so this module flask is not right now recognized by my Python interpreter so let me just exit from this interpreter by just pressing exit and now I'm going to just give CLS so in order to know more about a particular package you give this command Python search and the name of the package so in my case I want to just search for a package called flask and I'm going to press ENTER and it's going to give me a big list of package which are related to flasks so because flask is a popular package on Python package index that's why you can see so many options for the flask package so I'm going to once again clear the terminal and I'm going to install this package which is flask so in order to install the package you give this command pip install and the name of the package and then press ENTER and it's going to start downloading this package so now you can see this package is successfully installed on my system and you can see the version which is installed is flask one point zero point two now in order to know more about a particular package which you have already installed you can give this command so in order to know more about the package which you have already installed you give pip show and the package name and when I give this command you can see the name of the package is flask the version which is installed is one point zero point two and there is a brief summary of this package also which is available here and the home page for this project is also available here who is the author and all the other details about this package which you may find useful are given here using this command which is PIP show and the package name now after installing a package I'm going to verify if this package is available using the Python shell or not and once again I'm going to try to import this package which is flask and then press enter and you will be able to see now I don't see any error so if you don't see any error this means that this package is successfully installed and in future you will be able to import this package to use it on any of your Python script which you create after installing this package so let me once again exit from the Python shell and let me clear the command prompt once again now in order to list out all the packages which are installed on your system you can give this command which is pip list which is going to print the list of all the packages which is already installed on your system now in order to uninstall any package you just need to give this command PIP uninstall and the name of the package for example I want to uninstall this package which we have installed which is flask and I'm going to press enter and you can see it says uninstalling flask and it will ask you whether you want to proceed or not so you just need to press Y in order to proceed and once you press Y it's going to just uninstall that package from your system and at the end you will see this message which says successfully uninstalled and the package name which you have uninstalled you can once again give this command pip list and now you can see flask is no more in the list of installed packages so this is how you can use Python pip in order to install and manage your Python packages I hope you have enjoyed this blog and I will see you in the next blog you 

Post a Comment

Previous Post Next Post

Recent in Technology News