Understanding Python PIP: The Essential Package Manager
PIP is the standard package manager for Python, included by default in Python 3.4 and later. Discover what PIP is, learn about Python packages, and find out how to verify if PIP is installed on your system. This guide covers the essentials of managing Python modules efficiently.
Python PIP
What is PIP?
PIP is a package manager for Python packages, or modules if you like.
If you have Python version 3.4 or later, PIP is included by default.
What is a Package?
A package contains all the files you need for a module. Modules are Python code libraries you can include in your project.
Check if PIP is Installed
To check if PIP is installed, navigate your command line to the location of Python's script directory and type:
Example: Check PIP version
C:\Users\ThisPC\Python\packages>pip --version
Install PIP
If PIP is not installed, download and install it from https://pypi.org/project/pip/.
Download a Package
Downloading a package using PIP is straightforward:
Example:Download a package named "camelcase":
C:\Users\ThisPC\Python\packages>pip install camelcase
Using a Package
Once installed, import and use the package in your Python project:
Example: Import and use "camelcase"
import camelcase
c = camelcase.CamelCase()
txt = "i love python"
print(c.hump(txt))
#This method capitalizes the first letter of each word.
Output
I Love Python
Find Packages
Discover more Python packages at https://pypi.org/.
Remove a Package
To uninstall a package, use the following command:
Example: Uninstall the package named "camelcase"
C:\Users\ThisPC\Python\packages>pip uninstall camelcase
Uninstalling camelcase-02.1:
Would remove:
c:\users\ThisPC\appdata\local\programs\python\python36-32\lib\site-packages\camelcase-0.2-py3.6.egg-info
c:\users\ThisPC\appdata\local\programs\python\python36-32\lib\site-packages\camelcase\*
Proceed (y/n)?
Press y
and the package will be removed.
List Packages
To list all installed packages, run:
Example: List installed packages
C:\Users\ThisPC\Python\packages>pip list
Package Version
-----------------------
camelcase 0.2
mysql-connector 2.1.6
pip 18.1
pymongo 3.6.1
setuptools 39.0.1