> This page is for Itential Gateway, version 5 (default).
> For other versions, use one of these documentation indexes:
> - 5 (default): https://docs-test.itntl.com/itential-gateway/5/llms.txt
> - 4: https://docs-test.itntl.com/itential-gateway/4/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs-test.itntl.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-test.itntl.com/_mcp/server.

# Use executable objects with gateway services

> Configure Python services to use custom Python interpreters with executable objects.

You can use executable objects with Python services to specify a custom Python interpreter for your Python scripts. This allows different Python services to use different Python versions or configurations.

> **Info**
>
> While this topic focuses on Python services as an example, executable objects also work with Ansible and OpenTofu services.
>
> You can use executable objects to specify custom versions or installations of any supported tool.

## When to use executable objects with Python services

Use executable objects with Python services when you need to:

* Run different Python services with different Python versions (for example, Python 2 and Python 3)
* Use a Python interpreter installed in a non-standard location
* Use Python from a `conda` environment or `pyenv` installation
* Apply specific command-line flags to your Python interpreter

## Default behavior

If you don't specify an executable object, Python services use the system default Python interpreter. This maintains backward compatibility with existing Python services.

## Prerequisites

* An executable object configured with a Python interpreter path
* A Git repository that contains your Python script
* Operator role permissions
* Repository authentication configured (if using a private repository)

## Create a Python service with an executable object

Use the `iagctl create service python-script` command with the `--executable-object` parameter to create a Python service that uses a custom interpreter.

**Syntax:**

```bash
iagctl create service python-script <service-name> \
  --executable-object <object-name> \
  --repository <repository-name> \
  --working-dir <directory-path> \
  --filename <script-filename>
```

**Parameters:**

* `<service-name>`: A unique name for the Python service
* `--executable-object`: The name of the executable object that defines the Python interpreter
* `--repository`: The name of the Git repository that contains your Python script
* `--working-dir`: The path within the repository where your script is located
* `--filename`: The name of the Python script file to execute

**Example:**

Create a Python service that uses Python 3.11:

```bash
iagctl create service python-script simple-python \
  --executable-object python311-standard \
  --repository gateway-resources \
  --working-dir pythonscripts \
  --filename main.py
```

## Examples for different Python installations

### Use Python from a conda environment

```bash
iagctl create executable-object python-conda \
  --exec-command /opt/conda/envs/myenv/bin/python \
  --description "Python from conda environment"

iagctl create service python-script conda-python-service \
  --executable-object python-conda \
  --repository data-science-scripts \
  --working-dir analysis \
  --filename analyze.py
```

### Use Python from pyenv

```bash
iagctl create executable-object python-pyenv \
  --exec-command /home/user/.pyenv/versions/3.10.5/bin/python \
  --description "Python 3.10.5 from pyenv"

iagctl create service python-script pyenv-python-service \
  --executable-object python-pyenv \
  --repository automation-scripts \
  --working-dir python \
  --filename automation.py
```

### Use a specific Python version for testing

```bash
iagctl create executable-object python39-test \
  --exec-command /usr/bin/python3.9 \
  --description "Python 3.9 for compatibility testing"

iagctl create service python-script test-python-service \
  --executable-object python39-test \
  --repository test-suite \
  --working-dir tests \
  --filename run_tests.py
```

## Run a Python service with an executable object

Run Python services the same way you run other services:

```bash
iagctl run service python-script simple-python
```

Itential Gateway uses the executable object configuration to run your Python script with the correct Python interpreter.

## Static environments and executable objects

You cannot use static environments and executable objects together in the same Python service. If you configure a Python service with both a static environment and an executable object, Gateway returns an error.

Choose one of the following approaches for each Python service:

* Use a static environment for package management with the system Python interpreter
* Use an executable object to specify a custom Python interpreter without static environments