# Working with packages

DataLab is preconfigured with a recent version of Python and R and a host of commonly used data science and machine learning packages.

On top of that you can install additional packages or different versions of the pre-installed packages right from any notebook.

### Browsing pre-installed packages

Click on the "Environment > Pre-installed packages" in the notebook sidebar on the left. You can now browse and search an overview of all available packages. If you search for a package that is not pre-installed, you will get instructions on how to install that particular package. If you click "Add to notebook", the package install command will be added at the top of your notebook in a new code cell and immediately executed.<br>

<figure><img src="/files/3BaAlyTcoLVsNPzRZowo" alt="" width="375"><figcaption><p>Open up the list of Pre-installed packages</p></figcaption></figure>

<figure><img src="/files/GaQMMdYegNdFZ4XzxV8w" alt="" width="375"><figcaption><p>Package install instructions that appear if you want to install a package that is not yet available.</p></figcaption></figure>

### Installing additional packages

If a package you want to use is not pre-installed, you can install it yourself using as described below.

{% hint style="info" %}
Note that you need to reinstall packages every time your workbook session is restarted, which happens 5 minutes after closing the workbook tab or after 30 minutes of inactivity on the free plan.

To make this easy, keep track of additional package installs at the top of your notebook, so you can easily rerun the commands when you return to your workbook.
{% endhint %}

#### Python

To install additional packages, add `!pip install <name-of-pkg>` e.g. `!pip install pythonwhat` in a code cell. If you want to install a specific version of a package, including the ones that come pre-installed, use `!pip install <name-of-pkg>==<wanted-version>`.

If you want to suppress the output when installing additional packages, you can use `%%capture` in the line above the `!pip` command:

```
%%capture
!pip install PyPortfolioOpt==1.4.2
```

#### R

If you want to suppress the output when installing additional packages, you can use the `quiet = TRUE` argument:

```
install.packages("PortfolioAnalytics", quiet = TRUE)
```

You can also use `suppressMessages()`, `suppressWarnings()` and `suppressPackageStartupMessages()` to suppress output.

#### Resolving issues

If you encounter problems when installing packages, let us know through one of the channels described in [Get help](/resources/support.md).

{% hint style="warning" %}
Due to security reasons, currently not all packages can be installed.

In particular installing packages with native dependencies might fail partially or completely due to a lack of permissions to execute certain installation steps.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://datalab-docs.datacamp.com/work/code-cell/packages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
