Working with packages

How to work with packages
DataCamp Workspace is preconfigured a recent version of Python and R and a host of ocmmonly used data science and machine learning packages.

Browsing pre-installed packages

When in the Workspace editor, click on the Environment tab
in the 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.
Package install instructions that appear if you want to install an R package that is not yet available.

Installing additional packages

If a package you want to use is not pre-installed, you can install it yourself using as described below.
Note that you need to reinstall packages every time your workspace session is restarted, which happens 5 minutes after closing the workspace tab or after 30 minutes of inactivity.
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 workspace and to ensure that workspace publications can complete without issues.


To install additional packages, add !pip install <name-of-pkg> e.g. !pip install pythonwhat in a code cell. If you want to suppress the output when installing additional packages, you can use %%capture in the line above the !pip command:
!pip install PyPortfolioOpt


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 Support.
Due to security reasons, not all packages work in the DataCamp Notebook Editor at the moment. However, they are available in the JupyterLab editor. These packages usually add advanced outputs - like maps or plots - or load external scripts to work. You can switch to JupyterLab by using the button "Switch Editor" at the top of your screen.