PIP - Package Installer for Python
PyPI - Python Package Index
PyPI is the default repository of Python packages for Python community that includes frameworks, tools and, libraries. Python developers can install and use packages in the Python application. It is open to all Python developers to consume and distribute their distributions. Developers can search or browse projects from pypi.org.
PIP has been included with Python installer since Python 3.4. You can verify whether the pip is installed on your machine by running the following command in your console:C:\>pip --version
pip 18.0 from c:\python37\lib\site-packages\pip (python 3.7)
If you are using an older version of pip, you can upgrade pip by running the following command on Windows:C:\> python -m pip install -U pip
Execute the following command on Linux or Mac OS to upgrade pip:$ pip install -U pip
If pip isn't already installed, then first try to bootstrap it from the standard library by executing the following command in your console or terminal window:python -m ensurepip --default-pip
If that still doesn't install pip, the following steps should install pip on your platform.
get-pip.pyfrom https://bootstrap.pypa.io/get-pip.py and save it to your local folder.
Navigate command prompt or terminal to the folder where you have downloaded the file and run the command:
pip Help command
pip help command is used to get a list of all the functions available in pip.
pip <command> [options]
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependen cies.
config Manage local and global configuration.
search Search PyPI for packages.
cache Inspect and manage pip's wheel cache.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
debug Show information useful for debugging.
help Show help for commands.
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be
used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be
used up to 3 times (corresponding to WARNING,
ERROR, and CRITICAL logging levels).
--log <path > Path to a verbose appending log.
--no-input Disable prompting for input.
--proxy <proxy > Specify a proxy in the form [user:[email protected]]proxy.server:port.
--retries <retries > Maximum number of retries each connection should attempt (default 5 times).
--timeout <sec > Set the socket timeout (default 15 seconds).
--exists-action <action > Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
--trusted-host <hostname > Mark this host or host:port pair as trusted,
even though it does not have valid or any HTTPS.
--cert <path > Path to alternate CA bundle.
--client-cert <path > Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
--cache-dir <dir > Store the cache data in <dir >.
--no-cache-dir Disable the cache.
Don't periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with --no-index.
--no-color Suppress colored output
Silence deprecation warnings for upcoming
--use-feature <feature > Enable new functionality, that may be backward
--use-deprecated <feature > Enable deprecated functionality, that will be
removed in the future.
PyPI maintains packages as projects. Use the following pip command to install the latest version of the project.
Pip install "project-name"
Use the following command installs the specific version of the project:
pip install "project-name==2.4"
Use the following command to install a version that's "compatible" with a certain version:
pip install "project-name~=2.4"
Let's install a package to send an HTTP request in Python. urllib3 is a powerful, user-friendly HTTP client for Python. Before using urllib3 package in your application, install it using the
pip command, as shown below.
The above command will install the latest version of
urllib3. Now, you can import and use it, as shown below.
import urllib3 http = urllib3.PoolManager() req = http.request('GET', 'http://www.google.com') print(req.status)
The list command can be used to see all the packages that have been installed on the system. If you want to check all the packages, use the
pip list command:
This will list all the packages available to use in your system. Notice that
urllib3 package is also listed there.
If you want to check the metadata of a package, then use pip show command. The following command will display the metadata of the urllib3 package.C:\> pip show urllib3
Summary: HTTP library with thread-safe connection pooling, file post, and more.
Author: Andrey Petrov
Author-email: [email protected]
Uninstalling a Package
pip uninstall command can be used to remove a package. For example, if you want to remove
urllib3 package, you can simply use the following command:
The pip package manager will ask you to confirm if you want to uninstall the package.
If you press y, the package will be removed.
Thus, you can use pip as a package manager of your Python application.