Libraries and scripts for notebooks

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

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

Listing installed libraries

Before you install any libraries by way of a notebook, you should check if those libraries are already preinstralled in the runtime environment. If a library is not preinstalled, you should customize the environment definition and not add this library through the notebook. That way, the library is preinstalled each time the environment runtime is started. Libraries that you add to your environment runtime 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.

Bear in mind that you can only customize a environment definition that you created; you can’t customize the preset default environment definitions provided by Watson Studio.

Currently, you can only customize a default environment definition that you created. For all other environment types, namely Spark and GPU, you need to install custom or additional libraries through the notebook.

To see the list of installed libraries in your Watson Studio environment:

  1. Click your project’s Environments tab.
  2. From the Environment definitions list, click the environment definition you want to use. This opens the environment definition details page where you can see the list of installed libraries.
  3. Optional: Add custom libraries and packages. See customizating the software configuration.

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
This video shows how to use the machine learning libraries in a notebooks

Learn more