Functions to Find an Acceptable Python Binary

Package designed to find an acceptable python binary.

CRAN Status Badge

Build Status

AppVeyor Build Status

Coverage Status

RStudio CRAN mirror downloads

Project Status: Inactive -- The project has reached a stable, usable state but is no longer being actively developed; support/maintenance will be provided as time allows.

findpython is an R package that finds acceptable Python binaries for your program. Since there are often multiple python binaries installed on any given system and they aren't always added to the path this can be a non-trivial task.

To install the latest version released to CRAN use:


To install the development version use:


It has no dependencies (other than R) but if you have the suggested reticulate package installed it will also use it to try to find an acceptable python binary. You'll also need the suggested testthat package to run the unit tests.


find_python_cmd is the main function. It returns the path to a python binary that meets certain requirements you specify. Below are some examples.

If you need to find a Python 2 binary which is at least Python 2.4: > find_python_cmd(minimum_version = '2.4', maximum_version = '2.7') [1] "/usr/bin/python"

If you need to find a version of Python at least Python 2.5 (but don't care if it is a Python 3 binary):

> find_python_cmd(minimum_version = '2.5')
[1] "/usr/bin/python"

If you don't care what version of Python you use but it needs to have access to an argparse module as well as either the json OR simplejson module:

> find_python_cmd(required_modules = c('argparse', 'json | simplejson'))
[1] "/usr/bin/python"

Although find_python_cmd will create a basic default message if left unspecified you can use the error_message argument to specify what error message your program will output if it is unable to find an acceptable binary:

> error_message <- paste('Was unable to find the Python 4 binary dependency.',
+                         'See file INSTALL for more information.')
> find_python_cmd(minimum_version = '4.0', error_message = error_message)
Error in find_python_cmd(minimum_version = "4.0", error_message = error_message) : 
  Was unable to find the Python 4 binary dependency. See file INSTALL for more information.

There is also a wrapper for find_python_cmd that instead of throwing an error upon failing to find an appropriate Python command will return FALSE and if it finds an appropriate command will return TRUE. If successful it attaches the appropriate binary path as an attribute python_cmd:

> did_find_python <- can_find_python_cmd()
> python_cmd <- attr(did_find_python, "python_cmd")
> cat(did_find_python, python_cmd, "\n")
TRUE /usr/bin/python

The default error message will be something like:

> find_python_cmd(min='4.0')
Error in find_python_cmd(min = "4.0") : 
  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 4.0  

If you already have a python binary you want to check you can use is_python_sufficient to test whether it has sufficient features. It has the same arguments minimum_version, maximum_version, and required_modules as find_python_cmd:

> is_python_sufficient(path_to_binary, minimum_version = '2.6', required_modules = 'scipy')


This package is available under the MIT license.


findpython 1.0.5

  • Minor internal refactoring and documentation improvements.

findpython 1.0.4

  • No longer throws an unintended error when can't find a suitable python command AND reticulate package is not installed.

findpython 1.0.3

  • Uses reticulate::py_discover_config to find more python binaries if can't otherwise find a suitable python command.

findpython 1.0.2

  • Looks for more python binaries and likely folders in Windows (i.e. Python 3.5 through Python 3.9).
    Thanks Jori Liesenborgs for request.

findpython 1.0.1

  • Initial released version on CRAN.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.0.5 by Trevor L Davis, a month ago

Report a bug at

Browse source code at

Authors: Trevor L Davis [aut, cre] , Paul Gilbert [aut]

Documentation:   PDF Manual  

Task views: Numerical Mathematics

MIT + file LICENSE license

Suggests covr, reticulate, testthat

Imported by RWebLogo, argparse.

Depended on by popRange.

See at CRAN