Category: noteboook
Question: What are the features of the environment of Kaggle Notebooks?
Answer: Notebooks are more than just a code editor. They’re a versioned computational environment designed to make it easy to reproduce data science work. In the Notebooks IDE, you have access to an interactive session running in a Docker container with pre-installed packages, the ability to mount versioned data sources, customizable compute resources like GPUs, and more.

## Notebook Versions and Containers

When you create a Notebook version using 'Save & Run All', you execute the Notebook from top to bottom in a separate session from your interactive session. Once it finishes, you will have generated a new Notebook version. A Notebook version is a snapshot of your work including your compiled code, log files, output files, data sources, and more. The latest Notebook version of your Notebook is what is shown to users in the Notebook viewer.

Every Notebook version you create is associated with a specific Docker image version as well. Docker is a containerization technology which provides an isolated environment in which to do your work. Docker specifies the contents of this environment including installed Python and R packages using what is known as an image. Every Notebook version you create is associated with a Docker image.

By default for new notebooks, this will be the latest version of the default Python or R images that we maintain at Kaggle. The contents of this image is publicly available on GitHub. You may view it at [docker-rstats](https://github.com/Kaggle/docker-rstats) for the R container, or [docker-python](https://github.com/Kaggle/docker-python) for the Python container.

## Dockerfiles and Notebook Versions

Even if you are using one of the default Kaggle containers, the number, names, and versions of the packages that you’re using are still a moving target as our team continually updates them to ensure the latest and greatest packages are available. We update the images about every two weeks, mainly to upgrade to the latest versions of the packages we provide but also occasionally to add or remove certain packages. You can subscribe to notifications when we release a new Docker image on [GitHub](https://www.kaggle.com/product-feedback/161327).

It is also possible to pin a specific Docker image for use in a Notebook if there are multiple custom images available. This can be done by accessing the “Settings” tab in the Notebook editor. Next to "Environment", there is an option to select "Preferences." This opens a modal where you can select what your environment preference is between pinning to a specific image (the image version when your notebook was created) or always using the latest image. You can read more about these options [here](https://admin.kaggle.com/product-feedback/150261).

In order to ensure that your Notebooks remain reproducible, we publicly expose the Dockerfile defining the environment the Notebook version was created in. You may download the contents of that Dockerfile by visiting the "Execution Info” section on your Notebook and navigating to the “Container image” field.

## Modifying the Default Environment

You can request a modification to the default environment by submitting a pull request or an issue to the R [container](https://github.com/Kaggle/docker-rstats) or Python [container](https://github.com/Kaggle/docker-python) on GitHub. Be sure to explain why you think a package should be added to the default environment. We welcome pull requests and engagement with our public images if users believe there are new packages that will be helpful and used by a significant majority of our users.

More rarely, if you notice that something in our default environments broke, you may notify us of it using the same mechanism.

Note that, even if approved, it can take several days for requested packages to be added to the live container image on the website.

## Modifying a Notebook-specific Environment

It is also possible to modify the Docker container associated with the current Notebook image.

### Using a standard package installer

In the Notebook Editor, make sure "Internet" is enabled in the Settings pane (it will be by default if it's a new notebook).

For Python, you can run arbitrary shell commands by prepending ! to a code cell. For instance, to install a new package using pip, run `!pip install my-new-package`. You can also upgrade or downgrade an existing package by running `!pip install my-existing-package==X.Y.Z`.

To install packages from GitHub in R, load the devtools package by running `library(devtools)`. Then, you can run commands such as `install_github("some_user/some_package")` to install a new package from GitHub.