Installing Python packages on Db2 Warehouse

Application code that is written in Python often uses functions that are provided by Python packages. The installed packages are automatically available on each Db2 Warehouse node in a cluster.

While Python packages, such as numpy, can be provided also as Python egg files, it is more convenient to manage Python packages by using a package manager such as pip.

Note:

If the Python version that is used by Db2 Warehouse or Integrated Analytics System changes, previously installed packages cannot be accessed anymore. The change log indicates such changes and provides upgrade instructions.

For more information about changes and upgrade instructions, see the following websites:

On Db2 Warehouse:

To install a Python package on Db2 Warehouse and make it available for all users, do the following steps:

  1. Connect to the Db2 Warehouse node with an SSH client.
  2. On the Docker host node, from outside your Db2 Warehouse container, issue the following command:
    docker exec -it Db2wh /bin/bash
  3. Install the Python package for all users by issuing the following commands:
    su - bluadmin
    spark-pip install --root /mnt/blumeta0/site-python package name

On Integrated Analytics System

To install a Python package on Integrated Analytics System, do one of the following steps depending on whether you want to install the package for a single user or for all users:

  • To install a Python package for a single user on Integrated Analytics System, do the following steps:
    1. Connect to the Integrated Analytics System node as an arbitrary user by issuing the following command:
      ssh user@host -p 50022
      
      Where user is the name of the single user, and host is the name of the docker host.
    2. Install the Python package for a single user by issuing the following command:
      spark-pip install --user package name
  • To install a Python package for all users on Integrated Analytics System, do the following steps:
    1. Connect to the Integrated Analytics System node as the bluadmin user by issuing the following command:
      ssh bluadmin@host -p 50022
      Where host is the name of the docker host.
    2. Install the Python package for all users by issuing the following command:
      spark-pip install --root /mnt/blumeta0/site-python package name

    Based on the system setup of Integrated Analytics System for Python, these packages are automatically available for every user.