Skip to main content

Python Engine SDK

Importante

This Python SDK uses outdated technology that limits your extension opportunities. We've built a new Platform SDK using Python and the latest open-source technology to deliver a vastly improved development experience. Go to Platform SDK to get started!

Use the Alteryx Python SDK extension module to write custom Alteryx plugin tools, while accessing core elements of the AlteryxEngine framework.

When you create a custom tool with a Python back end, you will need to work with an SDK. For this reason, we assume you are familiar with Python and Python dependencies.

Importante

Python Tool Compatibility

Python versions vary between the releases of Alteryx, and may impact the compatibility and version requirements of your tool. See Alteryx Embedded Python for more information.

Python Tools on Gallery

To run a workflow with a Python SDK tool on Gallery, the workflow or app has to be set to Run Mode: Unrestricted. Server admins can change the workflow Run Mode. See Workflows: Admin Interface.Fluxos de trabalho: interface de administrador

Encryption on Server

User Encryption:

  • Cannot Be Used with Remote Servers

  • Not Portable to Other Users

Machine Encryption:

  • Cannot Be Used with Remote Servers

  • Can Only Be Decrypted on the Same Machine (or Server)

  • Does Not Require User Credential

  • Recommended for scheduling and uploading to local instances of Alteryx Analytics Gallery.

Python Installation

Run the Python executable found in your Alteryx installation location. The following commands assume the installation location is C:\Program Files\Alteryx\bin\Miniconda3\python.exe.

Run these commands:

import os, sys
os.environ['PATH'] = r'C:\program files\Alteryx\bin;' + os.environ['PATH']
sys.path.insert(1, r'C:\program files\Alteryx\bin\plugins')
import AlteryxPythonSDK

You should now be able to use the Python SDK.

SDK Use

Python SDK Environment

The Alteryx Python SDK is not designed to run in a standalone Python environment—it is invoked by the AlteryxEngine as part of an Alteryx workflow by initializing an embedded Python process that is specifically designed for interfacing with plugin modules. The Alteryx Python SDK is compiled to run on Python version 3.6.8 that is part of the Miniconda install currently included as part of the Alteryx Designer installation.

To use the Python SDK when you create your tool's back end, you need to create a Python file. The name should relate to the tool name, and the file needs to be saved in the tool folder.

\MyNiftyPlugin\MyNiftyPluginEngine.py

This file needs to use data gathered from the data stream and manipulate the data in accordance with the user input from the tool's GUI. It is recommended that you create the front-end first to connect to the tool's data items. If you have not already created the front end, see HTML GUI SDK or Macro.

To start the design of an Alteryx Python SDK plugin module, import the Alteryx Python SDK extension module at the beginning of your script.

import AlteryxPythonSDK

The main body of the script is implemented in the AyxPlugin class. The AlteryxEngine requires the AyxPlugin class when it runs your script. If you do not have the AyxPlugin class, or it is not named correctly, an attribute error exception occurs.

AttributeError: module '__main__' has no attribute 'AyxPlugin'

Additional classes are necessary depending on what you are creating. See Classes for an overview. See Data to manage data as records.

Python SDK Tools in Iterative and Batch Macros

Global variables do not reset between iterations in iterative or batch macros. The global variables will retain their value between iterations and need to be initialized directly by the Python SDK tool. Resetting global variables should happen in the __init__ method of the AyxPlugin class.

Import Additional Libraries

To ensure these dependencies do not conflict with any other tools in your workflow, use a virtual environment so each tool operates as a self-contained unit. See Virtual Environment and Dependencies. If using a virtual environment, a different process is required for packaging the tool as a .yxi. See YXI Packaging and Installation.

To see an example of successful implementation of a plugin, navigate to bin\HtmlPlugins\PythonSDKExample.