R: Import a Python module

import {reticulate} | R Documentation

## Import a Python module

### Description

Import the specified Python module for calling from R.

### Usage

    import(module, as = NULL, convert = TRUE, delay_load = FALSE)

    import_main(convert = TRUE)

    import_builtins(convert = TRUE)

    import_from_path(module, path = ".", convert = TRUE)

### Arguments

`module` | Module name
`as` | Alias for module name (affects names of R classes). Note that this is an advanced parameter that should generally only be used in package development (since it affects the S3 name of the imported class and can therefore interfere with S3 method dispatching).
`convert` | `TRUE` to automatically convert Python objects to their R equivalent. If you pass `FALSE` you can do manual conversion using the `py_to_r()` function.
`delay_load` | `TRUE` to delay loading the module until it is first used. `FALSE` to load the module immediately. If a function is provided then it will be called once the module is loaded. If a list containing `on_load()` and `on_error(e)` elements is provided then `on_load()` will be called on successful load and `on_error(e)` if an error occurs.
`path` | Path to import from

### Details

The `import_from_path` function imports a Python module from an arbitrary filesystem path (the directory of the specified python script is automatically added to the `sys.path`).

### Value

A Python module

### Examples

    ## Not run:
    main <- import_main()
    sys <- import("sys")

    ## End(Not run)

[Package reticulate version 1.15 Index]