Libraries and scripts for notebooks

Watson Studio includes many preinstalled libraries for Python and R in its runtime environments:

Note:

  • Brunel is not pre-installed on Watson Studio environments with Python version 3.7 or later.
  • PixieDust will not be pre-installed on Watson Studio environments with Python version 3.8 or later.

To work with Scala in a notebook, use a Spark environment.

Listing installed libraries

Many of your favorite open source libraries are pre-installed on Watson Studio 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
  • By adding a customization to the environment in which the notebook runs

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. Select the environment definition from the project’s Environments tab.
  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 environemnt. See customizating an environment definition.

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. Watch this video to see how to use the Spark Machine Learning Libraries.

Figure 1. Video iconUse the Spark Machine Learning libraries

Learn more