Both Ubuntu and Debian provide Python modules in their apt repositories, but it doesn't host the less popular modules. The version of the available Python modules is also tied to the version of Ubuntu or Debian.

You need to install Python modules from Python Package Index (PyPI) if you require the latest Python modules or those not hosted in apt repositories. pip allows installing Python packages hosted in PyPI, but it's not installed by default in Ubuntu or Debian. You can install pip on Ubuntu or Debian using apt at the terminal.

Steps to install pip on Ubuntu and Debian:

  1. Launch terminal.
  2. Update apt's package list.
    $ sudo apt update
    [sudo] password for user: 
    Hit:1 http://ports.ubuntu.com/ubuntu-ports impish InRelease
    Hit:2 http://ports.ubuntu.com/ubuntu-ports impish-updates InRelease
    Hit:3 http://ports.ubuntu.com/ubuntu-ports impish-backports InRelease
    Hit:4 http://ports.ubuntu.com/ubuntu-ports impish-security InRelease
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    All packages are up to date.
  3. Install python3-pip package using apt.
    $ sudo apt install --assume-yes python3-pip
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following additional packages will be installed:
      binutils binutils-aarch64-linux-gnu binutils-common build-essential dpkg-dev fakeroot g++ g++-11 gcc
      gcc-11 javascript-common libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
      libasan6 libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
      libctf-nobfd0 libctf0 libexpat1-dev libfakeroot libgcc-11-dev libhwasan0 libitm1 libjs-jquery
      libjs-sphinxdoc libjs-underscore liblsan0 libnsl-dev libpython3-dev libpython3.9-dev
      libstdc++-11-dev libtirpc-dev libtsan0 libubsan1 linux-libc-dev lto-disabled-list make manpages-dev
      python-pip-whl python3-dev python3-distutils python3-setuptools python3-wheel python3.9-dev
      rpcsvc-proto zlib1g-dev
    Suggested packages:
      binutils-doc debian-keyring gcc-11-doc gcc-multilib autoconf automake libtool flex bison gcc-doc
      gcc-11-locales apache2 | lighttpd | httpd glibc-doc libstdc++-11-doc make-doc python-setuptools-doc
    The following NEW packages will be installed:
      binutils binutils-aarch64-linux-gnu binutils-common build-essential dpkg-dev fakeroot g++ g++-11 gcc
      gcc-11 javascript-common libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl
      libasan6 libatomic1 libbinutils libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
      libctf-nobfd0 libctf0 libexpat1-dev libfakeroot libgcc-11-dev libhwasan0 libitm1 libjs-jquery
      libjs-sphinxdoc libjs-underscore liblsan0 libnsl-dev libpython3-dev libpython3.9-dev
      libstdc++-11-dev libtirpc-dev libtsan0 libubsan1 linux-libc-dev lto-disabled-list make manpages-dev
      python-pip-whl python3-dev python3-distutils python3-pip python3-setuptools python3-wheel
      python3.9-dev rpcsvc-proto zlib1g-dev
    0 upgraded, 53 newly installed, 0 to remove and 0 not upgraded.
    Need to get 143 MB of archives.
    After this operation, 463 MB of additional disk space will be used.
    ##### snipped

    Install python2-pip package instead if you're installing for Python 2.x.

  4. Check if pip's installation was successful.
    $ pip3 --version
    pip 20.3.4 from /usr/lib/python3/dist-packages/pip (python 3.9)

    Use pip2 instead if you've previously installed python2-pip.

  5. Start using pip on your system.
    ~$ pip3 --help
    
    Usage:   
      pip3 <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.
      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.
    
    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.
      --no-input                  Disable prompting for input.
      --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 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.
      --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.
      --no-python-version-warning
                                  Silence deprecation warnings for upcoming unsupported Pythons.
      --use-feature <feature>     Enable new functionality, that may be backward incompatible.
      --use-deprecated <feature>  Enable deprecated functionality, that will be removed in the future.
Discuss the article:

Comment anonymously. Login not required.