I am trying to build an app that will use a custom python tool that I'm trying to make with the sdk. I created a venv in the directory that I have my Gui, config, and engine files. As a test, I started python in the command prompt to make sure i am running the miniconda version that I need. When I do this, I see:
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
So far, this all looks good. However, when i do:
import AlteryxPythonSDK as Sdk
I get the error:
ModuleNotFoundError: No module named 'AlteryxPythonSDK'
Is this supposed to happen? I suspect that I need to use the:
class AyxPlugin:
that I see in all other examples to get it to work but am not 100% sure on this. Anyone able to offer some clarification
Solved! Go to Solution.
You need to add the following paths to sys.path and os.environ['PATH']
>>> import sys, os
>>> sys.path.append(r"C:\Program Files\Alteryx\bin\Plugins")
>>> os.environ['PATH'] += r";C:\Program Files\Alteryx\bin"
>>> import AlteryxPythonSDK as sdk
However, to run your custom tool it will need to be ran within Alteryx and requires the AyxPlugin class be present. Running Python and import AlteryxPythonSDK, only serves to provide access to Alteryx 'RecordCopier' 'RecordInfo' and 'Field' classes.
Do i add this at the top of my Engine.py file in all custom tools? I notice the examples on github don't have this. Or is it a one time add?
Got it. In that case, I need to actually run the tool in alteryx while trouble shooting?
Also, I made a new venv in the directory with my tool files. So the directory has my engine, gui, and config files but al a lib and script files. Will the tool know to use this venv? When I launch python from the directory, it starts my standard anaconda enviroment. But when I launch from the scripts file, I get the 3.6 Continuum distribution which I assume is the miniconda distro that I need for the sdk.
Yes, you will need to use Alteryx to debug/test your plugin. When you run your tool in an Alteryx workflow, it will find your virtual environment paths.