This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
08-25-2016 11:49 AM - edited 07-23-2021 12:29 PM
If you are using a version of Designer≥2018.3, use the Python tool! If you are on an older version, this article is for you.
Below is an example demonstrating the use of the Run Command tool to execute a Python script in the Designer and use its output in the workflow:
For a Python script, your Command should be Python.exe. If the directory where Python exists is in your system path variable, you can simply type Python.exe. Otherwise you will have to give it the full path, keeping in mind to quote the string if there are spaces (e.g. "Program Files"). In Command Arguments, you will type the location of your Python script (Alteryx's default working directory is the directory of the running module so it may be easiest to keep your script in the same folder to simply type "your_python_script.py" rather than the full path) and any - or -- options necessary. Remember to quote this string!
The example script from the attached simply sends text to a text file to be used as input for the Designer (note: it will not run unless you have configured your python environment😞
As you can see, we’ve successfully executed a python script and used the Read Results input to bring the result of the script into the Designer for further processing.
Thanks for the post.
I found the following to work for me to return some status codes to Alteryx workflow.
The first argument would pass the data to the python program
The second arugment would return the status code back to Alteryx
Using the %temp% ensures the process can run in parallel with other processes.
I downloaded the example and everything worked as described about but when I run my own scripts I receive "Error: Run Command (3): The external program "C:\Python27\python.exe" returned an error code: 2"
Any ideas?
@pbrink - What happen when you try to run the command from the terminal/cmd.exe? What error message do you get?
C:\Python27\python.exe python_program.py?
Although, with 18.3, you may want to check if the python tool can help in your situation https://help.alteryx.com/current/Python.htm
Thank you for the example, I have downloaded the workflow and it works perfectly. I do have a follow up question regarding the text.txt file. Why is that needed? I would like to run other py scripts how can I do that without having the text.txt file.
Thank you,
Pete
I am trying to call a python script that takes in no arguments, but when I add a run command it's asking for an input and output connection? I thought the input / output source are optional?
I have the same situation and question.
How can I execute my Python script which has not inputs or outputs?