use_python {reticulate} | R Documentation |
Use Python
Description
Select the version of Python to be used by reticulate
.
Usage
use_python(python, required = NULL)
use_python_version(version, required = NULL)
use_virtualenv(virtualenv = NULL, required = NULL)
use_condaenv(condaenv = NULL, conda = "auto", required = NULL)
use_miniconda(condaenv = NULL, required = NULL)
Arguments
python |
The path to a Python binary. |
required |
Is the requested copy of Python required? If |
version |
The version of Python to use. |
virtualenv |
Either the name of, or the path to, a Python virtual environment. |
condaenv |
The conda environment to use. For |
conda |
The path to a |
Details
The reticulate
package initializes its Python bindings lazily – that is,
it does not initialize its Python bindings until an API that explicitly
requires Python to be loaded is called. This allows users and package authors
to request particular versions of Python by calling use_python()
or one of
the other helper functions documented in this help file.
RETICULATE_PYTHON
The RETICULATE_PYTHON
environment variable can also be used to control
which copy of Python reticulate
chooses to bind to. It should be set to
the path to a Python interpreter, and that interpreter can either be:
A standalone system interpreter,
Part of a virtual environment,
Part of a Conda environment.
When set, this will override any other requests to use a particular copy of
Python. Setting this in ~/.Renviron
(or optionally, a project .Renviron
)
can be a useful way of forcing reticulate
to use a particular version of
Python.
Caveats
Note that the requests for a particular version of Python via use_python()
and friends only persist for the active session; they must be re-run in each
new R session as appropriate.
If use_python()
(or one of the other use_*()
functions) are called
multiple times, the most recently-requested version of Python will be
used. Note that any request to use_python()
will always be overridden
by the RETICULATE_PYTHON
environment variable, if set.
The py_config()
function will also provide a short note describing why
reticulate
chose to select the version of Python that was ultimately
activated.