---
file_format: mystnb
kernelspec:
  name: python3
  display_name: python3
---


# Install instructions

We generally recommend creating a [conda](https://anaconda.org) environment to isolate any code
from other dependencies. The `ISLP` package does not have unusual dependencies, but this is still
good practice. 

## Mac OS X / Linux

To create a conda environment in a Mac OS X or Linux environment run:

```{code-cell} ipython3
---
tags: [skip-execution]
---
conda create --name islp
```

To run python code in this environment, you must activate it:

```{code-cell} ipython3
---
tags: [skip-execution]
---
conda activate islp
```

## Windows

On windows, create a `Python` environment called `islp` in the Anaconda app. This can be done by selecting `Environments` on the left hand side of the app's screen. After creating the environment, open a terminal within that environment by clicking on the "Play" button.

# Installing `ISLP`

Having completed the steps above, we use `pip` to install the `ISLP` package:

```{code-cell} ipython3
---
tags: [skip-execution]
---
pip install ISLP
```

## Frozen environment

```{attention}

Python packages change frequently. The labs here are built
with specific versions of the various packages. 
```

To ensure you have the same package versions as those built here, run:

```{code-cell} ipython3
---
tags: [skip-execution]
---
pip install -r https://raw.githubusercontent.com/intro-stat-learning/ISLP_labs/v2_devel/frozen_requirements.txt
```

For more specific install instructions go to [ISLP_labs](https://github.com/intro-stat-learning/ISLP_labs/tree/v2_devel).

## Torch requirements

The `ISLP` labs use `torch` and various related packages for the lab
on deep learning. The requirements can be found
[here](https://github.com/intro-stat-learning/ISLP/blob/main/torch_requirements.txt). Alternatively, you can install them
directly using `pip` within a terminal. As above, ensure that you have
activated that conda environment (Mac OS or Linux) or started a
terminal within that environment from the Anaconda app (Windows).

```{attention}
Because
`torch` and related libraries change frequently, you will note that we
have pinned the versions at specific versions that were used to make
current verisons of the labs.
```

```{code-cell} ipython3
---
tags: [skip-execution]
---
pip install -r https://raw.githubusercontent.com/intro-stat-learning/ISLP_labs/v1/torch_requirements.txt
```

## Jupyter

### Mac OS X

If JupyterLab is not already installed, run the following after having activated your `islp` environment:

```{code-cell} ipython3
---
tags: [skip-execution]
---
pip install jupyterlab
```

### Windows

Either use the same `pip` command above or install JupyterLab from the
`Home` tab. Ensure that the environment is your `islp`
environment. This information appears near the top left in the
Anaconda `Home` page.

# Google Colab

The notebooks for the labs can be run in [Google
Colab](https://colab.research.google.com) with a few caveats:

- Labs that use files in the filesystem will require one to mount your
  Google Drive. See [help](https://colab.research.google.com/notebooks/io.ipynb)

- The packages will have to be reinstalled each time a new runtime is started.
For most labs, inserting `pip install ISLP` at the top of the notebook will suffice, though Colab will ask you to restart after installation.
