> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Script

export const ComponentMetadata = ({warehouses, unsupportedWarehouses = [], componentType, connectionInputs, connectionOutputs}) => {
  const allWarehouses = [...warehouses.map(w => ({
    name: w,
    supported: true
  })), ...unsupportedWarehouses.map(w => ({
    name: w,
    supported: false
  }))];
  return <div style={{
    background: 'var(--colors-background-light, #f9fafb)',
    border: '1px solid var(--colors-border-default, #e5e7eb)',
    borderRadius: '12px',
    padding: '20px 28px',
    marginBottom: '28px',
    boxShadow: '0 1px 4px rgba(0,0,0,0.10)'
  }}>
      <table style={{
    width: '100%',
    borderCollapse: 'collapse'
  }}>
        <tbody>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle',
    width: '180px'
  }}>Project Availability</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>
              <div style={{
    display: 'flex',
    flexWrap: 'wrap',
    gap: '8px'
  }}>
                {allWarehouses.map((w, i) => <span key={i} style={{
    background: w.supported ? '#dcfce7' : '#fee2e2',
    color: w.supported ? '#15803d' : '#b91c1c',
    border: `1px solid ${w.supported ? '#bbf7d0' : '#fca5a5'}`,
    borderRadius: '9999px',
    padding: '3px 12px',
    fontSize: '0.85rem',
    fontWeight: '500',
    whiteSpace: 'nowrap'
  }}>
                    {w.name} {w.supported ? '✅' : '❌'}
                  </span>)}
              </div>
            </td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Component Type</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{componentType}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Inputs</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{connectionInputs}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Outputs</td>
            <td style={{
    verticalAlign: 'middle'
  }}>{connectionOutputs}</td>
          </tr>
        </tbody>
      </table>
    </div>;
};

export const m_runner = "Maia runner";

export const maia = "Maia";

<ComponentMetadata warehouses={["Snowflake", "Databricks", "Amazon Redshift"]} unsupportedWarehouses={["BigQuery"]} componentType="Orchestration, Test" connectionInputs="One" connectionOutputs="Unlimited" />

Run a Python script. The script is executed in-process by the Python 3 interpreter.

Any output written via **print** statements will appear as the task completion message, and so output should be brief.

While it is valid to handle exceptions within the script using try/except, any uncaught exceptions will cause the component to be marked as failed and its failure link to be followed.

You may import any modules from the Python Standard Library. Optionally, you may also import your own Python libraries. To do this, you need to specify the location of your libraries in the environment variable `EXTENSION_LIBRARY_LOCATION`. For more information on this, read [Optional {m_runner} parameters](/docs/guides/optional-runner-parameters). To use these additional Python libraries, you will need to include appropriate imports in your Python script, following standard Python practice.

If the component requires access to a cloud provider, by default the component will inherit the {m_runner}'s execution role (service account role). However, if there are [cloud credentials](/docs/guides/cloud-credentials) associated to your environment, these will overwrite the role.

This component supports the use of pipeline and project variables. For more information, read [Project and pipeline variables](/docs/guides/variables).

<Note>
  Python scripts in {maia} should be written to be version-agnostic where possible. The Python runtime bundled with the {m_runner} is updated periodically, and there is no guarantee a specific version will remain in place indefinitely. Read [Installing Python libraries](/docs/guides/installing-python-libraries) for further information.
</Note>

<Warning>
  Currently, this component isn't usable on {maia} [Full SaaS](/docs/guides/runner-overview#matillion-full-saas) infrastructure or the [{m_runner} for Snowflake](/docs/guides/snowflake-runner-install). See the [Python Pushdown](/docs/components/python-pushdown) component for a way to run Python scripts in your own Snowflake environment if you have a Full SaaS solution.
</Warning>

***

## Properties

<ResponseField name="Name" type="string" required>
  A human-readable name for the component.
</ResponseField>

{/* <!-- param-start:[script, script1] | warehouses: [snowflake, databricks, redshift] --> */}

<ResponseField name="Script" type="code editor" required>
  The Python script to execute.
</ResponseField>

{/* <!-- param-start:[interpreter] | warehouses: [snowflake, databricks, redshift] --> */}

<ResponseField name="Interpreter" type="drop-down" required>
  Set this to **Python 3**.
</ResponseField>

{/* <!-- param-start:[timeout] | warehouses: [snowflake, databricks, redshift] --> */}

<ResponseField name="Timeout" type="integer" required>
  The number of seconds to wait for script termination. After the set number of seconds has elapsed, the script is forcibly terminated. The default is 300 seconds (5 minutes).
</ResponseField>

## Script best practices

In a Python script, it's possible to stream all of the output of a massive `curl` request to the log output. However, we don't recommend this practice. Streaming all of the data to the log means that the data leaves your own infrastructure and is stored in log files in {maia}, breaking data sovereignty.

Best practice, therefore, is to use the script to retrieve the data and then load it into an S3 bucket or some other storage of your choice, bypassing the Matillion logs.

If your Python script results in a log file of more than 300 KB being written, the script will execute successfully but the component will truncate the log file and log the message `*** WARNING: log output too large. Only returning the last 300 KB **** : <contents>`

***

## Default libraries

The following libraries are available by default in the Python Script component:

| a-d                       | d-n                        | n-s                  | s-z                |
| ------------------------- | -------------------------- | -------------------- | ------------------ |
| abc                       | distutils                  | nntplib              | slugify            |
| agate                     | doctest                    | ntpath               | smtpd              |
| aifc                      | docutils                   | nturl2path           | smtplib            |
| annotated\_types          | dsi\_pydantic\_shim        | numbers              | sndhdr             |
| antigravity               | email                      | numpy                | snowplow\_tracker  |
| apiclient                 | encodings                  | oauthlib             | socket             |
| apt                       | enum                       | opcode               | socketserver       |
| apt\_inst                 | errno                      | openpyxl             | softwareproperties |
| apt\_pkg                  | et\_xmlfile                | OpenSSL              | sortedcontainers   |
| aptsources                | faulthandler               | operator             | soupsieve          |
| argparse                  | fcntl                      | optparse             | spwd               |
| array                     | filecmp                    | ordered\_set         | sqlite3            |
| asn1crypto                | fileinput                  | os                   | sqlparams          |
| ast                       | filelock                   | ossaudiodev          | sqlparse           |
| asynchat                  | fnmatch                    | packaging            | sre\_compile       |
| asyncio                   | fractions                  | pandas               | sre\_constants     |
| asyncore                  | ftplib                     | pandas\_gbq          | sre\_parse         |
| atexit                    | functools                  | parsedatetime        | ssl                |
| attr                      | future                     | pathlib              | stat               |
| attrs                     | gc                         | pathspec             | statistics         |
| audioop                   | genericpath                | pdb                  | string             |
| autocommand               | getopt                     | pickle               | stringprep         |
| awscli                    | getpass                    | pickletools          | struct             |
| azure\_identity           | gettext                    | pip                  | subprocess         |
| azure\_keyvault\_secrets  | gi                         | pipes                | sunau              |
| babel                     | glob                       | pkg\_resources       | symtable           |
| backports                 | google\_auth\_httplib2     | pkgutil              | sys                |
| base64                    | google\_auth\_oauthlib     | platform             | sysconfig          |
| bdb                       | google\_crc32c             | platformdirs         | syslog             |
| binascii                  | googleapiclient            | plistlib             | tabnanny           |
| binhex                    | graphlib                   | poplib               | tarfile            |
| bisect                    | grp                        | posix                | telnetlib          |
| blinker                   | grpc                       | posixpath            | tempfile           |
| boto3                     | grpc\_status               | pprint               | termios            |
| botocore                  | gzip                       | profile              | test               |
| bs4                       | hashlib                    | proto                | text\_unidecode    |
| builtins                  | heapq                      | pstats               | textwrap           |
| bz2                       | hmac                       | psycopg2             | this               |
| cachetools                | html                       | pty                  | threading          |
| cairo                     | http                       | pwd                  | thrift             |
| calendar                  | httplib2                   | py\_compile          | time               |
| certifi                   | idna                       | pyarrow              | timeit             |
| cffi                      | imaplib                    | pyasn1               | token              |
| cgi                       | imghdr                     | pyasn1\_modules      | tokenize           |
| cgitb                     | imp                        | pyclbr               | tomli              |
| chardet                   | importlib                  | pycparser            | tomlkit            |
| charset\_normalizer       | importlib\_metadata        | pydantic             | trace              |
| chunk                     | inflect                    | pydantic\_core       | traceback          |
| click                     | inspect                    | pydata\_google\_auth | tracemalloc        |
| cmath                     | io                         | pydoc                | tty                |
| cmd                       | ipaddress                  | pydoc\_data          | turtle             |
| code                      | isodate                    | pyexpat              | typeguard          |
| codecs                    | itertools                  | pygtkcompat          | types              |
| codeop                    | jeepney                    | pyparsing            | typing             |
| collections               | jinja2                     | pytimeparse          | typing\_extensions |
| colorama                  | jmespath                   | pytz                 | typing\_inspection |
| colorsys                  | json                       | queue                | tzdata             |
| compileall                | jsonschema                 | quopri               | unicodedata        |
| concurrent                | jsonschema\_specifications | random               | unittest           |
| configparser              | jwt                        | re                   | uritemplate        |
| contextlib                | keyring                    | readline             | urllib             |
| contextvars               | keyword                    | redshift\_connector  | urllib3            |
| copy                      | launchpadlib               | referencing          | uu                 |
| copyreg                   | leather                    | reprlib              | uuid               |
| cProfile                  | lib2to3                    | requests             | venv               |
| crypt                     | linecache                  | requests\_oauthlib   | wadllib            |
| cryptography              | locale                     | resource             | warnings           |
| csv                       | logging                    | rlcompleter          | wave               |
| ctypes                    | lsb\_release               | roman                | weakref            |
| curses                    | lxml                       | rpds                 | webbrowser         |
| daff                      | lz4                        | rsa                  | wheel              |
| databricks                | lzma                       | runpy                | wsgiref            |
| dataclasses               | mailbox                    | s3transfer           | xdrlib             |
| datetime                  | mailcap                    | sched                | xml                |
| dateutil                  | markupsafe                 | scramp               | xmlrpc             |
| db\_dtypes                | marshal                    | secrets              | xxlimited          |
| dbm                       | mashumaro                  | secretstorage        | xxlimited\_35      |
| dbt                       | math                       | select               | xxsubtype          |
| dbt\_common               | mimetypes                  | selectors            | yaml               |
| dbt\_extractor            | mmap                       | setuptools           | zipapp             |
| dbt\_semantic\_interfaces | modulefinder               | shelve               | zipfile            |
| dbus                      | more\_itertools            | shlex                | zipimport          |
| decimal                   | msgpack                    | shutil               | zipp               |
| deepdiff                  | multiprocessing            | signal               | zlib               |
| difflib                   | netrc                      | site                 | zoneinfo           |
| dis                       | networkx                   | sitecustomize        |                    |
| distro                    | nis                        | six                  |                    |
