Customizing with pip
You can add custom packages from the Python Package Index, PyPI without access to the public network.
You can use these methods to add custom packages:
- Configuring pip to use a proxy server
- Using pip from IBM Cloud Pak for Data storage
- Using pip from Project storage
Required roles:
- You must be a Cloud Pak for Data cluster administrator to create a pip configuration file
pip.conf
. - You need Admin or Editor permissions on the analytics project to create an environment template and add a software configuration.
Configuring pip to use a proxy server
You can configure pip for use behind a proxy server by creating your own clusterwide pip configuration file called pip.conf
in which you can specify your own package index or a proxy user.
-
Create a new pip configuration file or open the existing one at
/user-home/_global_/config/conda/pip.conf
. The names of the settings inpip.conf
are derived from the long command-line option. Use the following options to configure your corporate proxy and an internal package index:[global] proxy=http://user:password@proxy_name:port index-url=http://internal-pip-index.internal.com/root/pypi/+simple/ trusted-host=internal-pip-index.internal.com
-
Copy the
pip.conf
file to the shared file system:ibm_nginx_pod=`oc get pods -l component=ibm-nginx -o jsonpath='{.items[0].metadata.name}'` oc cp pip.conf ${ibm_nginx_pod}:/user-home/_global_/config/conda/pip.conf
Configuring pip from IBM Cloud Pak for Data storage
You can add a custom Python distribution package to IBM Cloud Pak for Data storage and then access these packages directly from within a notebook. Alternatively, you can add a configuration to your environment runtime with the file path to the package where it can be picked up by the runtime builds.
- Create a Python project with a setup.py build script.
- Generate a distribution package.
-
Upload the zipped archive file to
/user-home/_global_/config/conda
.ibm_nginx_pod=`oc get pods -l component=ibm-nginx -o jsonpath='{.items[0].metadata.name}'` oc exec ${ibm_nginx_pod} -- chmod a+r "/user-home/_global_/config/conda/<package_name>"
-
Create an environment template in the Watson Studio project and add a customization for pip:
# Add conda channels below defaults, indented by two spaces and a hyphen. channels: - nodefaults # Add conda packages here, indented by two spaces and a hyphen. dependencies: # Add pip packages here, indented by four spaces and a hyphen. # Remove the comments on the following lines and replace sample package name with your package name. - pip: - file:///user-home/_global_/config/conda/Archive.zip
Configuring pip from project storage
You can add a custom Python distribution package to your analytics project in Watson Studio and then add a configuration to your environment template with the file path to the data assets folder in the project.
- Create a Python project with a setup.py build script.
- Generate a distribution package.
- Upload the zipped distribution file to your project as a data asset.
-
Create an environment template in your Watson Studio project and add a customization:
# Add conda channels below defaults, indented by two spaces and a hyphen. channels: - nodefaults # Add conda packages here, indented by two spaces and a hyphen. dependencies: # Add pip packages here, indented by four spaces and a hyphen. # Remove the comments on the following lines and replace sample package name with your package name. - pip: - file:///project_data/data_asset/Archive.zip
If your environment is air-gapped and you do not plan to use any conda packages from external sources, create a .condarc
file in the same folder with the following content:
offline: True
This ensures that conda filters out all channels that do not use the file://
protocol.
Parent topic: Customization options for conda and pip