# FindPythonInterp

Changed in version 3.27: This module is available only if policy `CMP0148` is not set to `NEW`.

Deprecated since version 3.12: Use `FindPython3`, `FindPython2`, or `FindPython` instead.

Finds the Python interpreter and determines the location of its executable:

    find_package(PythonInterp [<version>] [...])

Note

When using both this and the `FindPythonLibs` module, call `find_package(PythonInterp)` before `find_package(PythonLibs)`. This ensures that the detected interpreter version is used to guide the selection of compatible libraries, resulting in a consistent `PYTHON_LIBRARIES` value.

Note

A call to `find_package(PythonInterp ${V})` for Python version `V` may find a `python` executable with no version suffix. In this case no attempt is made to avoid Python executables from other versions. Use `FindPython3`, `FindPython2`, or `FindPython` instead.

## Result Variables

This module defines the following variables:

`PythonInterp_FOUND`

  Added in version 3.3.

  Boolean indicating whether the (requested version of) Python executable was found.

`PYTHON_VERSION_STRING`

  Python version found (e.g., `2.5.2`).

`PYTHON_VERSION_MAJOR`

  Python major version found (e.g., `2`).

`PYTHON_VERSION_MINOR`

  Python minor version found (e.g., `5`).

`PYTHON_VERSION_PATCH`

  Python patch version found (e.g., `2`).

## Cache Variables

The following cache variables may also be set:

`PYTHON_EXECUTABLE`

  The path to the Python interpreter.

## Hints

This module accepts the following variables before calling `find_package(PythonInterp)`:

`Python_ADDITIONAL_VERSIONS`

  This variable can be used to specify a list of version numbers that should be taken into account when searching for Python.

## Deprecated Variables

The following variables are provided for backward compatibility:

`PYTHONINTERP_FOUND`

  Deprecated since version 3.12: Use `PythonInterp_FOUND`, which has the same value.

  Boolean indicating whether the (requested version of) Python executable was found.

## Examples

Finding the Python interpreter in earlier versions of CMake:

    find_package(PythonInterp)
    execute_process(COMMAND ${PYTHON_EXECUTABLE} --help)

Starting with CMake 3.12, the Python interpreter can be found using the `FindPython` module. The equivalent example using the modern approach is:

    find_package(Python)
    execute_process(COMMAND ${Python_EXECUTABLE} --help)