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.
So, this should be fairly straightforward, but for the life of me I cannot figure it out. I have a Python script and I would like to run it in Alteryx. So I am using the command tool, telling it to run cmd.exe, I am attaching my script in the command arguments box and in the read results box I have added the file to which it should write.
Yet when I go and run it, it opens up the command line box but nothing happens, it seems that it is not picking up the argument and running it.
The Run Command Tool options are a bit strangely worded so I will just walk through it in case this is your issue:
Write source will take whatever data is coming IN to the tool, that is the data stream that is attached to the input of the Run Command, and write it to the file or connection specified.
The point of this is to dump the data that is currently in Alteryx to a file so that your script can then read the file.
Under 'Run External Program Command:' 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 argument, you will type the location of your Python script your_python_script.py (Alteryx's default working directory is the directory of the running module so if is easiest to keep your script nearby and simply type "your_python_script.py" instead of the full path) and any - or -- options necessary. Remember to quote this string.
The default working directory for Alteryx is the directory of the running module unlesss set otherwise.
Your Python script should then write to a fileat the end of it's processing.
The Read Results should point to the file written by your Python script. This way, Alteryx can read back in the data that was procesed by the external command.
Clear as mud?
I actually just published a blog that, while not specifically on this topic, does show a couple of different examples of using the Run Command Tool to run an Rscript. This will be very similar to your setup.
That is the error that you see when the python script itself has an error
The best way to troubleshoot these kind of issues is to open your command prompt and run the script from there. Remember to change directories so that you are running from the same working directory as Alteryx, which is by default where the module is saved.
So from the command prompt:
'path_to_python.exe path_to_script.py --options'
When you run the script this way you should see the full output of the issue causing the error.
Once you have addressed these errors, try running it again in Alteryx.
Hi Michael, Alteryx is giving me an error that the Read Results file does not exist. The Read Results is what the external command will generate and send back to Alteryx, right? Which menas that in most cases this file will not exist prior to the execution of the command. I appreciate your help
Yes, often times the file in Read Results will not exist prior to the first run. This means that Alteryx will complain about not being able to find the file. Try running the module anyway and Alteryx should realize what is going on.
Othewise, you could create a dummy file so that Alteryx has something to look at.