The prefered way of installing additional Python libraries to use in a notebook is to customize the software configuration of the environment runtime associated with the notebook. You can add the conda or PyPi packages through a customization
template when you customize the environment template.
However, if you want to install packages from somewhere else or packages you created on your local machine, for example, you can install and import the packages through the notebook.
To install packages other than conda or PyPi packages through your notebook:
Add the package to your project storage by clicking the Upload asset to project icon ,
and then browsing the package file or dragging it into your notebook sidebar.
Add a project token to the notebook by clicking More > Insert project token from the notebook action bar. The code that is generated by this action initializes the variable project, which is required to access
the library you uploaded to object storage.
Example of an inserted project token:
# @hidden_cell# The project token is an authorization token that is used to access project resources like data sources, connections, and used by platform APIs.from project_lib import Project
project = Project(project_id='7c7a9455-1916-4677-a2a9-a61a75942f58', project_access_token='p-9a4c487075063e610471d6816e286e8d0d222141')
pc = project.project_context
# Fetch the library file, for example the tar.gz or whatever installable distribution you createdwithopen("xxx-0.1.tar.gz","wb") as f:
f.write(project.get_file("xxx-0.1.tar.gz").read())
# Install the library
!pip install xxx-0.1.tar.gz
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.