Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Python tool - %Run command is returning invalid syntax in Production Mode

KKR_Bond
5 - Atom

HI , 

I am trying to  call a external python script using run command in Python too. 

This command is working  fine in interactive mode but failing with invalid syntax when i switch to production mode and run the workflow .

 

Can i run the workflow from gallery keeping scripts in shared drive ?

 

Appreciate if anyone  has solution to fix this.

interactive Mode 

KKR_Bond_1-1582928452111.png

 

Production mode 

KKR_Bond_2-1582928508595.png

 

2 REPLIES 2
AndrewKramer
Alteryx Alumni (Retired)

Production mode converts your Jupyter Notebook into a Python script that is executed directly against the command line. Thus, Jupyter Magics, such as %run will not work.

 

In the .py file you want to run, I recommend reorganizing your code into a function which you can then call with Alteryx.importPythonModule, where yourFunction() is the function in file.py that you would like to call

py_script = Alteryx.importPythonModule("file.py")

py_script.yourFunction()

 

 

KKR_Bond
5 - Atom

Thanks AndrewKrammer, I am able  call python script as explained   

Labels