JMP® has a jpip wrapper that is just a thin wrapper around pip as such functionality, like installing packages via a requirements file, is fully supported. Below are two scripts, one JSL and one Python. Each uses a JSL Pick File() dialog to have the user select the requirements file, and the path is then passed through to jmputis.jpip() to process the requirements file. The majority of the code shown is utilizing the file selection dialog. With a hardcoded path it can be done in two lines of Python:
from jmputils import jpip
jpip('install', '-r _path_to_requirements.txt')
There is only one small trick to making this work.
The jmputils.jpip() function is just a wrapper on top of pip to ensure packages are installed in the isolated JMP environment. Installing and using a requirements file is simple. Due to the wrapper, this needs to be expressed in a specific way. The ‘-r ‘ to the pip command must immediately be followed by the file name. To ensure that, it should be placed with the ‘package’ string parameter to jpip. The code below should work for JMP 18.0 and newer. These examples will be in the Scripting Index in JMP 19.
From JSL
Names Default To Here(1);
src_path = Pick File(
"Select requirements.txt File",
"$DOCUMENTS",
{"TXT Files|txt", "All Files|*"},
0,
0,
"requirements.txt"
);
If( Host is("Windows"),
src_path = Convert File Path( src_path, windows )
);
Python Send(src_path);
Python Submit("\[
from jmputils import jpip
jpip('install', f'-r {src_path}')
]\");
From Python
import jmp
from jmputils import jpip
jmp.run_jsl('''
Names Default To Here( 1 );
src_path = Pick File(
"Select requirements.txt File",
"$DOCUMENTS",
{"TXT Files|txt", "All Files|*"},
0,
0,
"requirements.txt"
);
show(src_path);
If( Host is("Windows"),
src_path = Convert File Path( src_path, windows )
);
show(src_path);
Python Send(src_path);
''')
jpip('install', f'-r {src_path}')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.