import_module: Import Python modules

View source: R/import.R

import_moduleR Documentation

Import Python modules

Description

This function can be used to import LaminDB Python modules with additional checks and nicer error messages.

Usage

import_module(module, ...)

Arguments

module

The name of the Python module to import

...

Arguments passed on to require_module

options

A vector of defined optional dependencies for the module that is being required

version

A string specifying the version of the module to require

source

A source for the module requirement, for example ⁠git+https://github.com/owner/module.git⁠

python_version

A string defining the Python version to require. Passed to reticulate::py_require()

silent

Whether to suppress the message showing what has been required

Details

Python dependencies are set using require_module() before importing the module and used to create an ephemeral environment unless another environment is found (see vignette("versions", package = "reticulate")).

Requirements for the lamindb module can be controlled using environment variables differently, see https://docs.lamin.ai/setup-laminr for details.

Value

An object representing a Python package

See Also

  • require_module() and reticulate::py_require() for defining Python dependencies

  • vignette("versions", package = "reticulate") for setting the Python environment to use (or online here)

Examples

## Not run: 
# Import lamindb to start interacting with an instance
ln <- import_module("lamindb")

# Import lamindb with optional dependencies
ln <- import_module("lamindb", options = c("dev"))

# Import other LaminDB modules
bt <- import_module("bionty")
pt <- import_module("pertdb")
cc <- import_module("clinicore")

# Import any Python module
np <- import_module("numpy")

## End(Not run)

laminr documentation built on March 13, 2026, 5:08 p.m.