Find a suitable python cmd or give error if not possible
Source:R/find_python_cmd.r
find_python_cmd.Rdfind_python_cmd() finds a suitable python cmd or raises an error if not possible
Usage
find_python_cmd(
minimum_version = NULL,
maximum_version = NULL,
required_modules = NULL,
error_message = NULL
)Arguments
- minimum_version
The minimum version of python it should be. Should be a string with major and minor number separated by a
.. If left NULL won't impose such a restriction.- maximum_version
The maximum version of python it should be. Should be a string with major and minor number separated by a
.. If left NULL won't impose such a restriction.- required_modules
Which modules should be required. Can use a single
|to represent a single either-or requirement like"json|simplejson". If leftNULLwon't impose such a restriction.- error_message
What error message the user will see if couldn't find a sufficient python binary. If left NULL will print out a default message.
Value
The path to an appropriate python binary. If such a path wasn't found then it will throw an error.
See also
can_find_python_cmd() for a wrapper which doesn't throw an error
Examples
try(find_python_cmd())
#> [1] "/usr/bin/python3.10"
try(find_python_cmd(minimum_version = "2.6", maximum_version = "2.7"))
#> Error in find_python_cmd(minimum_version = "2.6", maximum_version = "2.7") :
#> Couldn't find a sufficient Python binary. If you haven't installed the Python dependency yet please do so. If you have but it isn't on the system path (as is default on Windows) please add it to path or set options('python_cmd'='/path/to/binary') or set the PYTHON, PYTHON2, or PYTHON3 environmental variables. Python must be at least version 2.6 Python must be at most version 2.7
try(find_python_cmd(required_modules = c("argparse", "json | simplejson")))
#> [1] "/usr/bin/python3.10"