- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Notify Moderator
Tired of asking for admin rights to install Python libraries in Alteryx? Discover a simple way to manage your packages without needing admin access—and make it work across all machines and servers. No more 'it works on my machine' excuses!
If it works on my machine, it should work everywhere… right?
When running Alteryx locally, installing Python libraries requires admin privileges. The same issue applies to coworkers who need to run your workflow. On Alteryx Server, even if the libraries are installed locally, you still need to ask server admins to install them on the server. This can be a hassle for everyone. But what if you could manage Python packages in Alteryx without needing admin access, and make it work everywhere?
Source: The "Works on My Machine" Certification Program
A Simple Trick to Make Python Packages Work Everywhere
To skip the admin privileges step (but hey, check with your server admin and manager before setting this up), here's a solution: set up a shared network folder for your Python libraries. This way, you can easily access and import the necessary libraries without needing to install them on every machine or server. Plus, the best part is everyone will be using the same exact library version—no more “it works on my machine” excuses.
First, let's take the baby steps
Using the Alteryx Python component and Alteryx.installPackages function, install the required libraries to a shared network folder accessible to all users.
# Step 1: Install packages in a shared folder (run this once)
from ayx import Alteryx
# Replace the target folder in the code below!
Alteryx.installPackages(['selenium', 'openpyxl', 'pyautogui'],
install_type= r'install --target=\\network_folder_path\shared_libraries')
Now, you can append this network folder to Python’s module search path, enabling Alteryx to import the libraries from there. Your folder will be shown in the last position of the printed list.
# Step 2: Append the shared folder to Python's path
import sys
sys.path.append(r'\\network_folder_path\shared_libraries')
print(sys.path)
Finally, you can import your libraries from any machine that has access to the folder. This will happen automatically because of the previous step:
# Step 3: Import modules
# Import the installed libraries
import selenium, openpyxl, pyautogui
Building momentum
Instead of hardcoding the packages path, you can parametrize the location on your code and use text inputs to pass it.
Using Alteryx.read
, import the dataframe containing the path. With iloc
and os.path
, turn the dataframe into a path for Python.
# Step 1: Transform a Python package path from a DataFrame cell
from ayx import Alteryx
import os
df_pythonPackages = Alteryx.read("#pythonPackages")
newPythonPackagePath = os.path.abspath(str(df_pythonPackages.iloc[0, 0]))
print(newPythonPackagePath)
Now, assign the variable that contains the package location to the target.
# Step 2: Install packages in a shared folder (run this once)
# Install packages into a shared folder (run this once)
Alteryx.installPackages(package=["pdfplumber", "beautifulsoup4"], install_type=f"install --target={newPythonPackagePath}")
Then assign this same variable to the sys path append method.
# Step 3: Append the shared folder to Python's path
import sys
sys.path.append(f"{newPythonPackagePath}")
print(sys.path)
Finally, you can import your libraries from any machine that has access to the folder. This will happen automatically because of the previous step:
# Step 4: Import the installed libraries
import pdfplumber, beautifulsoup4
Tip: You can also parametrize the libraries to import/install in the same way that you did for the package!
Mastering the game
You can even share workflows with the Python library already packed. Just export your workflow as a package, open the package with a zip manager (I use 7-zip, it's an open-source software), and add the Python Packages folder inside of it. The workflow must be parametrized to import the libraries with relative paths. By doing this, the end user can just run the workflow, and everything will run on the first try.
I did this for this community gallery workflow; you can download and take a look: Community Gallery - Convert .xls, .xlsm and .xlsb into .xlsx and parse the input.
Tip: You can do almost everything I've done here with R as well. You can do almost everything I've done here with R as well. Maybe in the future I'll do a post for R :).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.