What is Python Pip? – How to get started

As an Amazon Associate I earn from qualifying purchases.

3 Min Read

Pip is Python’s package manager (which has been included with Python since 3.4). It allows you to install, remove and manage packages that do not come as part of the standard packages bundled with Python. If you are working on any Python project, using pip to manage your external packages is a must. Packages from pip can be found at PyPi which is a repository of packages for Python.

Getting started

As of Python 3.4, pip is bundled with Python. The easiest way to see if Pip is already installed is to run the following command in the terminal.

pip --version

If pip is installed, you will be able to see the version that is installed:

C:\Users\conor>pip --version
pip 21.0.1 from c:\users\conor\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)

Installing pip

If pip is not installed on your computer, it can install 2 different ways depending on your preference. You can install pip by either upgrading your Python version to the latest(recommended) or by running the get-pip.py script provided by the developer.

Install pip by upgrading Python

My recommended approach is to upgrade Python. You can do this by grabbing the latest install files by heading over to the downloads section of the Python website. From here, you will be able to choose the latest version of Python (3.9.2 as of writing this article). Once installed, verify you have the latest version of Python and pip by using the following commands:

C:\Users\conor>python --version
Python 3.9.2

C:\Users\conor>pip --version
pip 21.0.1 from c:\users\conor\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)

Install pip by running the script

If you do not want to upgrade your version of Python, you can use the script provided by the pip developers to install pip.

Download the install script by running the following command on the terminal. This will work for Windows, MacOS and Linux:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Now run the following command to install pip:

python get-pip.py

How to use pip

Installing a package

Pip is extremely easy to use! Find the package you want on https://pypi.org/ and then run the following command to install the package:

pip install <YOUR LIBRARY>

E.g if I want to install the pandas library I would run the following:

pip install pandas

Removing a package:

If you have installed a package that you no longer require, you can run the following command to delete the package:

pip uninstall <YOUR PACKAGE>

To uninstall the pandas library, run the following command:

pip uninstall pandas

Listing installed packages

Finding out all the packages that are currently installed is easy. Just run the following command:

pip list

Additional help

A full list of command used for pip can be found by running pip --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.
  config                      Manage local and global configuration.
  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.
  --proxy <proxy>             Specify a proxy in the form [user:passwd@]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 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.
  --disable-pip-version-check
                              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

Interested in creating your own algo trading bot? Check out my free series on algo trading here: https://www.conorjohanlon.com/category/algotrader/

As always, if you have any questions or comments please feel free to post them below. Additionally, if you run into any issues please let me know.

Leave a Comment

Your email address will not be published.

Subscribe to my newsletter to keep up to date with my latest posts

Holler Box