find_python: Heuristics to Find Python

View source: R/find_python.R

find_pythonR Documentation

Heuristics to Find Python

Description

If you are using the {rosettaPTF} package for the first time you will need to have Python installed to obtain the necessary modules. You can set up {reticulate} to install into a virtual or Conda environment. Usually {reticulate} should cover most or all of the setup.

Usage

find_python(
  envname = NULL,
  pypath = NULL,
  arcpy_path = getOption("rosettaPTF.arcpy_path")
)

Arguments

envname

As in reticulate::py_install(): The name, or full path, of the environment in which Python packages are to be installed. When NULL (the default), the active environment as set by the RETICULATE_PYTHON_ENV variable will be used; if that is unset, then the r-reticulate environment will be used.

pypath

Optional: Path to python executable

arcpy_path

Optional: Path to ArcGIS Pro Python installation. For example: "C:/Program Files/ArcGIS/Pro/bin/Python". Set as NULL to prevent use of ArcGIS Pro instance.

Details

If you have Python set up correctly you should be able to run reticulate::py_config() or reticulate::py_discover_config() and discover your shared library.

A common problem with {reticulate} is not pointing at the correct (or any) python binary or libpython shared library. Use reticulate::use_python("/path/to/python", required = TRUE) to set the path or, alternately, be sure python can be found on your PATH. {reticulate} has a preference for Python environments that have numpy installed.

Windows / Miniconda

Use reticulate::install_miniconda() if you'd like to install a Miniconda Python environment. Conda is default on Windows.

For devices with limited ability to install new software that have ArcGIS Pro installed (some USDA computers), this method can look for a Python installation in "C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3" and Conda executable in "C:/Program Files/ArcGIS/Pro/bin/Python/Scripts". The base file path to "Python" directory can be customized using the arcpy_path argument.

Linux and OS X

On Linux and OS X you can create a virtual environment using reticulate::virtualenv_create(). The default environment name will be "r-reticulate".

Value

character path to python or NULL if no suitable environment can be found. The result is stored as the package option rosettaPTF.python_path.

Examples


find_python()


ncss-tech/rosettaPTF documentation built on Jan. 7, 2025, 4:20 a.m.