Customizing environment templates
As Admin or Editor of a project, you can change the name, the description, and the hardware configuration of an environment template that you created. You can also customize the software configuration of Jupyter
notebook environment templates by adding pip packages.
You customize the software configuration of Jupyter notebook environment templates by using pip. You can do this by providing a list of pip packages.
- If you customized the software configuration of an environment or plan to install additional libraries within a notebook, but do not change the configuration of
pip, the runtimes that are started with a customization must have public network access. - The default environment templates use the time zone where they were created, which is UTC time. If you want to use your local time in your code, ask the administrator to modify the runtime definition file to use your time zone.
Watch the following video to see how to create a custom environment template for a Jupyter notebook.
This video provides a visual method to learn the concepts and tasks in this documentation.
To customize an environment template that you created:
- Under Tool runtimes on the Environments page on the Manage tab of your project, check that no runtime is active for the environment template that you want to change. If a runtime is active, you must stop it before you can change the template.
- Under Templates on the Environments page, select the template that you want to customize and add your changes. You can't change the language of an existing environment template.
- If the template is a Juypter notebook environment template, you can create a software customization and specify the libraries to add to the standard packages that are available by default. You can also use the customization to upgrade or downgrade packages that are part of the standard software configuration.
- Apply your changes.
The libraries that are added to an environment template through the customization aren't persisted. They are automatically installed each time the runtime is started. Note that if you add a library using pip install through a notebook
cell and not through the customization, only you will be able to use this library. The library is not available to someone else using the same environment template.
You can use the provided templates to add custom libraries. Different templates exist for Python and for R. The following example shows the Python template:
# Modify the following content to add a software customization to an environment.
# To remove an existing customization, delete the entire content and click Apply.
# To add packages through pip, remove the comment on the following line.
# 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:
# - a_pip_package==1.0
Important when customizing:
- Before you customize a package, verify that the changes that you are planning have the intended effect.
pipdoes install the package. However, restarting the environment after verification will remove the package. You can verify the changes from your notebook. For example, for thePlotlylibrary:- In a Python notebook, enter:
!pip install plotly - In an R notebook, enter:
print(system2("pip", args="install plotly", stdout=TRUE))
- In a Python notebook, enter:
- If you add packages through
pipto the customization template, you must make sure that thedependencieskey is not commented out in the template. A customization with apippackage that does not start with thedependencieskey will generate an error. - Wherever possible, provide a package version number, even if the version that you want to use is the latest and you expect the package manager to select it. Providing a version number significantly reduces time and memory consumption during package installation.
- When you specify a package version, use a double
==forpippackages. If the version that you specify causes a dependency conflict that the package manager can resolve, a different or newer version might be installed. If you don't specify a version, the package manager might pick the latest version available, or keep the version that is in the package. - You cannot add arbitrary notebook extensions as a customization because notebook extensions must be pre-installed.