I am developing a custom tool in Alteryx Designer and using the Alteryx Python SDK for the implementation. However, I am facing a ModuleNotFoundError when trying to import the AlteryxPythonSDK module. Here's my code:
from ayx import Alteryx
import AlteryxPythonSDK as Sdk
def process_tool(input_anchor, output_anchor):
# Read the incoming data from the input anchor
incoming_record_info = input_anchor.get_record_info(input_anchor)
# Create the outgoing data with the same structure as the incoming data
outgoing_record_info = Sdk.RecordInfo(input_anchor)
outgoing_record_info.init_from_input_record_info(incoming_record_info)
# Set the predefined column names for row number 3
predefined_columns = ['Column A', 'Column B', 'Column C', 'Column D', 'Column E']
# Create a new row for the column names
outgoing_row = outgoing_record_info.construct_record()
# Write the predefined column names to the outgoing row
for idx, column_name in enumerate(predefined_columns):
outgoing_row[idx] = column_name
# Push the outgoing row to the output anchor
output_anchor.push_record(outgoing_row)
# Forward the incoming data to the output anchor
for record in input_anchor:
output_anchor.push_record(record)
# Instantiate the Alteryx tool object
tool = Sdk.AlteryxTool(1, 1)
# Get the input and output anchors
input_anchor = tool.get_input_anchor(0)
output_anchor = tool.get_output_anchor(0)
# Process the tool using the custom function defined above
process_tool(input_anchor, output_anchor)
When running the script, I get the following error:
ModuleNotFoundError: No module named 'AlteryxPythonSDK'
I have tried installing the ayx-python-sdk package using pip, but it says that the requirement is already satisfied.
1: I have upgraded pip to the latest version 2: After running the pip did restart the application and system just to make sure all is in sync 3: Checked a sample code which not using python sdk, and it is working.