community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Offline R and Python Package Installation

Alteryx
Alteryx

Sometimes, you just want to build something that requires R or Python, but the machine you want to run the workflow on may not have internet connectivity, which turns into a roadblock.

Thankfully, the below steps should get you up and solving in no time!  

Here’s how:

 

R

In the below R script, you specify the package you want to download, which in this case, is Prophet.

You then specify where you want the package + dependencies to be downloaded, and the script will create a CSV file with these names.

Once downloaded, you then can transfer the packages (either via a shared drive, USB etc.), and in the ‘OFFLINE’ part, point to where you want to install the packages from.

And that’s it!

 

The nice part about being able to run this inside the R tool in Alteryx is that it protects any of the packages that Alteryx needs!

 

Script:

 (full credit for this script goes to the authors of https://www.r-bloggers.com/installing-packages-without-internet/)

#ONLINE PART:

 

#' Get package dependencies

#'

#' @param packs A string vector of package names

#'

#' @return A string vector with packs plus the names of any dependencies

getDependencies <- function(packs){

  dependencyNames <- unlist(

    tools::package_dependencies(packages = packs, db = available.packages(),

                                which = c("Depends", "Imports"),

                                recursive = TRUE))

  packageNames <- union(packs, dependencyNames)

  packageNames

}

 

# Calculate dependencies

packages <- getDependencies(c("prophet"))

 

 

# Download the packages to the working directory.

# Package names and filenames are returned in a matrix.

setwd("C:/Users/your_login/Documents/R/temp")

pkgInfo <- download.packages(pkgs = packages, destdir = getwd(), type = "win.binary")

# Save just the package file names (basename() strips off the full paths leaving just the filename)

write.csv(file = "pkgFilenames.csv", basename(pkgInfo[, 2]), row.names = FALSE)

 

 

#OFFLINE PART:

# Set working directory to the location of the package files

setwd("C:/Users/your_login/Documents/R/temp/")

# Read the package filenames and install

pkgFilenames <- read.csv("pkgFilenames.csv", stringsAsFactors = FALSE)[, 1]

install.packages(pkgFilenames, repos = NULL, type = "win.binary", lib="C:/Users/your_login/Documents/R/win-library/3.5")

 

 

 

Python

For offline installation of Python packages, please follow the below steps:

  1. Download the package that you need (e.g. download Seaborn from https://github.com/mwaskom/seaborn)
  2. You then copy the downloaded file onto a shared drive, USB etc.
  3. Navigate to C:\Users\your_login\AppData\Local\Alteryx\bin\Miniconda3\PythonTool_venv\Scripts in command prompt
  4. Move the zip that you’ve downloaded to that to that folder
  5. Run pip install seaborn-master.zip (aka your package name)
  6. Import seaborn in Alteryx python tool to ensure no errors
Alteryx Partner

Why don't Alteryx build an "Designer extended edition"?

 

An Alteryx designer download that contains every available 

  • R package and
  • Python package available in the universe to date of release...

all you can eat.png

 

Labels