Hi everyone,
Alteryx Designer in 2019.3 has introduced some changes to how Python environment for (not only) Python Code tool is managed. Finally this allows us to utilize conda, which was (to my best knowledge) not possible in previous versions. Unfortunately for packages management at this time only (env not yet), but still awesome!
For those of you who don't know Conda - Conda is an open source package management system and environment management system. Find out more at https://docs.conda.io/projects/conda/en/latest/index.html
Why should you care about conda?
Well, Python Code tool in Alteryx relies on pip to fetch packages when you call the Alteryx.installPackages().
What if that does not work for whatever reason? Maybe the package is only available at anaconda.org, or maybe you need to work with non-Python dependencies which pip simply won't install.
While we are at it - Pip installs Python packages whereas conda installs packages which may contain software written in any language. It does not mean that pip and conda cannot coexist, you can actually rely on both to manage your environment. Its just that the two together are stronger than either of them alone.
Note: Currently there is a hardcoded conda env for Python code tool and you cannot simply change this.
It will be something like "C:\Program Files\Alteryx\bin\Miniconda3\envs\JupyterTool_vEnv"
Currently conda is limited to allow package management, not yet env management.
So why do I bother writing all this?
I had a problem installing Facebook's Prophet package to do some time series modelling. There were issues with pystan C++ compiler not working correctly, only CONDA INSTALL works...
So.... CONDA to the rescue. Take the following code snippets as just a sample of what you can achieve.
You can check out more here on packages management, or use this nice cheatsheet.
You should be easily able to utilize CONDA from CMD (C:\Program Files\Alteryx\bin\Miniconda3\Scripts\conda.exe) to install the package you need... (Use this reference on Conda's website for more details)
conda init cmd.exe #You need to init the cmd.exe env, requires restart of cmd
conda info --envs #List all your available envs
conda activate JupyterTool_vEnv #Activate the env of your choice
conda list #This will give you list of all currently installed packages
conda install -c conda-forge fbprophet #This did the trick to install package i needed
Just like Batman said....
Just in time! Great post David
Great post @DavidM and I look forward to using this tool.
However, I wonder if you had any resolution for the Command Line error I am receiving when following instructions below "Program is not recognized as an internal or external command, operable program or batch file."
- we do not have admin rights on laptop, not sure if this plays a factor
adding @CharlieS who was helping me at local user group.
Hi @jd,
I believe this will be permissions related. Can you please try to escalate with your IT to add you permissions to call CONDA.EXE in the directory you have printscreened?
Cheers
dm
FYI: After installing fbprophet and when I ran
import pandas as pd
from fbprophet import Prophet
I ran into a warning: Importing plotly failed. Interactive plots will not work
Running: pip install --upgrade plotly seems to fix the issue.
###########################
I will retract my previous comment because I'm not sure if that is necessary...Sorry!
But here is an issue that I ran into
When I ran
import matplotlib.pyplot as plt
m.plot(forecast)
plt.xlim('2014-01-01','2022-01-01')
I got an error :
ConversionError: Failed to convert value(s) to axis units: '2014-01-01'
Running the following :
pd.plotting.register_matplotlib_converters()
I was able to fix the error. Additional info is found here
Thanks,
Dhanushka
I am trying to run the conda exe but all that happens is a screen pops up quickly and then disappears. Is this possibly permission related?
Got it... thank you! @DavidM
Thank you for this.
conda activate JupyterTool_vEnv does not work, I have to use conda activate C:/"Program Files"/Alteryx/bin/Miniconda3/envs/JupyterTool_vEnv
I am new to Anaconda, and somehow I could not install fbprophet just by following the steps posted. Here is how I finally installed it -
Step 2 - Find your path to JupyterTool_vEnv, using command conda info --envs
I have to install the package in environment 'JupyterTool_vEnv', or it won't work in Alteryx.
try running this command conda config --set ssl_verify no and then re-run the install command.