DataLab Docs
  • What is DataLab?
  • Work
    • Creating a workbook
    • Sharing a workbook
    • Managing a workbook
    • Code cell
      • Working with packages
    • Text cell
      • Including images
    • SQL cell
      • SQL scenarios
      • Parameterize your SQL query
    • Explore Data cell
    • Chart cell
      • Configuring your chart
      • Pivot charts
      • Migration guide
    • AI Assistant
    • Version history
    • Scheduled runs
    • Hiding and showing cells
    • Long-running cells
    • Report view
    • Environment variables
    • Git and GitHub
  • Connect to Data
    • Connect your data to DataLab
    • Sharing a Data Source
    • Airtable
    • Amazon Athena
    • Amazon S3
    • Databricks
    • Dropbox
    • Files
    • Google Drive
    • Google BigQuery
    • Google Sheets
    • MariaDB
    • Microsoft SQL Server
    • MongoDB
    • MotherDuck
    • MySQL
    • Oracle Database
    • PostgreSQL
    • Redshift
    • Snowflake
    • Supabase
  • Guides
    • Publish a notebook
    • Importing data from flat files
    • Resizing plots
    • Show Bokeh and Pyvis plots
  • Resources
    • Pricing
    • Manage group settings
    • Reporting for Group Admins
    • DataLab for education
    • Technical requirements
    • Addressing slow code
    • Address R vulnerability
    • Get help
Powered by GitBook
On this page
  • Browsing pre-installed packages
  • Installing additional packages

Was this helpful?

  1. Work
  2. Code cell

Working with packages

How to work with packages

PreviousCode cellNextText cell

Last updated 11 months ago

Was this helpful?

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.

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 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.

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.

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.

Open up the list of Pre-installed packages
Package install instructions that appear if you want to install a package that is not yet available.