This function will install Tensorflow and all Keras dependencies. This is a thin wrapper around tensorflow::install_tensorflow(), with the only difference being that this includes by default additional extra packages that keras expects, and the default version of tensorflow installed by install_keras() may at times be different from the default installed install_tensorflow(). The default version of tensorflow installed by install_keras() is "2.6".

  method = c("auto", "virtualenv", "conda"),
  conda = "auto",
  version = "default",
  tensorflow = version,
  extra_packages = NULL,



Installation method. By default, "auto" automatically finds a method that will work in the local environment. Change the default to force a specific installation method. Note that the "virtualenv" method is not available on Windows.


The path to a conda executable. Use "auto" to allow reticulate to automatically find an appropriate conda binary. See Finding Conda for more details.


TensorFlow version to install. Valid values include:

  • "default" installs 2.6

  • "release" installs the latest release version of tensorflow (which may be incompatible with the current version of the R package)

  • A version specification like "2.4" or "2.4.0". Note that if the patch version is not supplied, the latest patch release is installed (e.g., "2.4" today installs version "2.4.2")

  • nightly for the latest available nightly build.

  • To any specification, you can append "-cpu" to install the cpu version only of the package (e.g., "2.4-cpu")

  • The full URL or path to a installer binary or python *.whl file.


Synonym for version. Maintained for backwards.


Additional Python packages to install along with TensorFlow.


other arguments passed to reticulate::conda_install() or reticulate::virtualenv_install(), depending on the method used.


The default additional packages are: tensorflow-hub, scipy, requests, pyyaml, Pillow, h5py, pandas, with their versions potentially constrained for compatibility with the requested tensorflow version.

Custom Installation

install_tensorflow() or keras::install_keras() isn't required to use tensorflow with the package. If you manually configure a python environment with the required dependencies, you can tell R to use it by pointing reticulate at it, commonly by setting an environment variable:

Sys.setenv("RETICULATE_PYTHON" = "~/path/to/python-env/bin/python")

Apple Silicon

Tensorflow on Apple Silicon is not officially supported by the tensorflow maintainers. It is known that there can be issues running the official Tensorflow package under Rosetta as well. Fortunately, for the time being Apple has published a custom version of Tensorflow compatible with M1 macs. Installation instructions can be found at: Please note that this is an experimental build of both python and tensorflow. After following the instructions provided by Apple, you can advise reticulate to use that python installation by placing the following in your .Renviron file:

RETICULATE_PYTHON = "~/miniforge3/bin/python"

Additional Packages

If you wish to add additional PyPI packages to your Keras / TensorFlow environment you can either specify the packages in the extra_packages argument of install_tensorflow() or install_keras(), or alternatively install them into an existing environment using the reticulate::py_install() function. Note that install_keras() includes a set of additional python packages by default, see ?keras::install_keras for details.

See also