BookmarkSubscribe
Choose Language Hide Translation Bar

Anaconda Environments Integration

Anaconda is one of the most used Python distributions for Data Science, as it makes it very easy to install pre-tested libraries along with their dependencies. Anaconda allows the user to organize the installed libraries in virtual environments to prevent said dependencies from interfering with each other. This script allows a JMP user to take advantage of this feature in order to keep its Python dependencies separated and well organized.

 

The attached Anaconda.jsl script allows a user to specify an Anaconda environment to execute Python code that depends on the specific dependency versions installed in that environment. It does so by providing a wrapper around the Python Init() command that identifies the required arguments that will make it match the given Anaconda environment. For example:

 

conda = Include("anaconda.jsl");
If(!conda:init(1), // debug mode
	Show(Get Current Directory());
	Throw("Conda initialization failed."));
Show(conda:get_envs());
// change as appropriate; use a Python 3.6 Conda environment name.
// 3.7 supported but must be specified
my_env = "py3"; If(!conda:is_env(my_env), Throw("Bad Conda environment, please use another one.")); conda:launch_env(my_env, 1); // debug mode Python Submit("\[ import numpy as np v = np.array([[1, 2], [3, 4]]) d = int(np.linalg.det(v)) print(d) ]\" ); dNum = Python Get(d); Show(dNum);

The attached .zip file includes other examples, including one that uses the Python libraries requests and beautifulSoup4 to web scrape data for analysis in JMP.

For more details on creating and re-using Anaconda virtual environments, see:

Current limitations:

  • Anaconda detection only works on Windows for now;
  • conda.exe must be in your PATH;
  • All examples work fine in 15.1. All examples with the exception of goldenglobes.jsl (the web scraping example) work on 14.3.
Article Tags
Contributors