Modules {XRPython} | R Documentation |
Import a Python module or add a directory to the Python Search Path
Description
If called from the source directory of a package during installation, both pythonImport
and pythonAddToPath()
also set up
a load action for that package. The functional versions, not the methods themselves, should
be called from package source files to ensure that the load actions are created.
Usage
pythonImport(..., evaluator, where = topenv(parent.frame()))
pythonAddToPath(directory = "python",
package = utils::packageName(topenv(parent.frame())), pos = NA, evaluator,
where = topenv(parent.frame()))
Arguments
... , where |
arguments for the |
evaluator |
The evaluator object to use. Supplying this argument suppresses the load action. |
directory |
the directory to add, defaults to "python" |
package , pos |
arguments |
Functions
-
pythonImport
: Add the module and name information specified to the objects imported for Python evaluators. -
pythonAddToPath
: Add the directory specified to the search path for future Python objects.
Examples
## Not run:
## How to search from a local directory, import a function from a file there
## and call the function.
## Including the evaluator argument causes the path change and import to happen
## right now, not in a package being loaded
ev <- RPython()
pythonAddToPath("/Users/me/myPython/", package = "",
evaluator = ev)
pythonImport("funEx", "foo", evaluator = ev)
pythonCall("foo", 1.1, 1.2)
## End(Not run)