"pip/pip3" Python Package Manager

Provides a tutorial example on how to use 'pip/pip3' command to install and manage Python packages.

When you develop Python applications, you may need to install additional Python packages developed by third parties. The best tool to manage those third party packages is the "pip/pip3" command as demonstrated in this tutorial.

1. Show "pip3" command options to manage Python3 packages.

herong$ pip3 help

Usage:
  pip <command> [options]

Commands:
  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 dependencies.
  search           Search PyPI for packages.
  wheel            Build wheels from your requirements.
  hash             Compute hashes of package archives.
  completion       A helper command used for command completion.
  help             Show help for commands.

General Options:
  -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.

2. Get a list of installed Python3 packages:

herong$ pip3 list

asn1crypto (0.24.0)
blivet (3.1.0)
Brlapi (0.6.7)
cffi (1.11.5)
chardet (3.0.4)
chrome-gnome-shell (0.0.0)
configobj (5.0.6)
coverage (4.5.1)
cryptography (2.3)
...

3. Search for a package to handle JSON strings. I see a list of JSON packages. I am not sure which is better.

herong$ pip3 search json

json-escape (1.0.0)              - Json escape
json-websocket (0.2.1582880480)  - json-websocket
json-dotenv (0.0.21)             - json-dotenv
mo-json (3.57.20089)             - More JSON Tools!
json-mindiff (0.1)               - Minimize json diffs
linaro-json (2.0.1)              - JSON Schema Validator
json-logging (1.0.6)             - JSON Python Logging
json-repository (0.2.0)          - A simple json repository
pygments-json (0.1)              - Pygments JSON formatter
pretty-json (1.2.0)              - make pretty json
...

4. Sometimes, "pip3" command may fail due to network connection issue. Just try it again later.

herong$ pip3 search json
Retrying (Retry(total=4, connect=None, read=None, redirect=None, ...
...
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/pip/_vendor/urllib3/connection.py"
  ...
OSError: [Errno 101] Network is unreachable

5. If you think your "pip3" command is outdated, you can use "pip3" to upgrade itself.

herong$ pip3 install --upgrade pip

6. Run "pip3" with the "python3 -m pip" command. This works because "pip" is actually a Python3 module.

herong$ python3 -m pip help

Usage:
  /usr/bin/python3 -m pip <command> [options]
  ...

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Software Package Manager on CentOS - DNF and YUM

 Running Apache Web Server (httpd) on Linux Systems

 Running PHP Scripts on Linux Systems

 Running MySQL Database Server on Linux Systems

Running Python Scripts on Linux Systems

 Install and Manage Python Engine on CentOS

"pip/pip3" Python Package Manager

 Install MySQL Connector/Python on CentOS

 Install Python 2 Engine on CentOS

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 GCC - C/C++ Compiler

 Conda - Environment and Package Manager

 Tools and Utilities

 References

 Full Version in PDF/EPUB