0 / 0
Libraries and scripts for notebooks

Libraries and scripts for notebooks

Watson Studio includes a large selection of preinstalled open source libraries for Python and R in its runtime environments. You can also use preinstalled IBM libraries or install custom libraries.

Watson Studio includes the following libraries and the appropriate runtime environments with which you can expand your data analysis:

  • The Watson Natural Language Processing library in Python and Python with GPU runtime environments.
  • The gespatio-temporal library in Spark with Python runtime environments
  • The Xskipper library for data skipping uses the open source in Spark with Python runtime environments
  • Parquet encryption in Spark with Python runtime environments
  • The tspy library for time series analysis in Spark with Python runtime environments

Listing installed libraries

Many of your favorite open source libraries are pre-installed on runtime environments. All you have to do is import them. See Import preinstalled libraries and packages.

If a library is not preinstalled, you can add it:

  • Through the notebook

    Some libraries require a kernel restart after a version change. If you need to work with a library version that isn't pre-installed in the environment in which you start the notebook, and you install this library version through the notebook, the notebook only runs successfully after you restart the kernel.

    Note that when you run the notebook non-interactively, for example as a notebook job, it fails because the kernel can't be restarted.

  • By adding a customization to the environment in which the notebook runs

    If you add a library with a particular version to the software customization, the library is preinstalled at the time the environment is started and no kernel restart is required. Also, if the notebook is run in a scheduled job, it won't fail.

    The advantage of adding an environment customization is that the library is preinstalled each time the environment runtime is started. Libraries that you add through a notebook are persisted for the lifetime of the runtime only. If the runtime is stopped and later restarted, those libraries are not installed.

To see the list of installed libraries in your environment runtime:

  1. From the Manage tab, on the project's Environments page, select the environment template.

  2. From a notebook, run the appropriate command from a notebook cell:

    • Python: !pip list --isolated
    • R: installed.packages()
  3. Optional: Add custom libraries and packages to the environment. See customizing an environment template.

Importing an installed library

To import an installed library into your notebook, run the appropriate command from a notebook cell with the library name:

  • Python: import library_name
  • R: library(library_name)

Alternatively, you can write a script that includes multiple classes and methods and then import the script into your notebook.

Learn more

Parent topic: Notebooks and scripts

Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more