cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

Install and use local custom Python module

robot
Level VI

Is there a best practice to install and use a local Python module in the JSL environment?

 

I read the documentation at Install Python Packages using JSL, and this seems geared for standard libraries.  Is there a default location where JMP looks for custom modules?

 

Is there a way to manage custom module updates using JSL?

 

Are there any differences for working with custom modules, packages, or libraries?

1 ACCEPTED SOLUTION

Accepted Solutions


Re: Install and use local custom Python module

JMP will just 'find it' if it is in the same directory as the launching .jsl or .py script.  There is an issue in JMP 18.0 if the launching script is .jsl, it doesn't find the .py import.  

 

It should work fine from both .jsl or .py scripts in 18.1+

 

The other way is to create a pyproject.toml file, put the script into a directory of the same name as the file and an appropriate pyproject.toml file.  This makes it an installable package which jpip can then install into the JMP site-packages/ location.  See Python.org's docs or many other tutorials on creating installable Python packages.  Such as: https://til.simonwillison.net/python/pyproject

 

 The code below is quick and dirty and probably doesn't follow python best practices.  I think there is usually an __init__.py file and __main__.py or main.py instead of the file matching the package directory...  But the toml file lets you specify lots if things including dependancies as show below.

 

dt2pandas/

    dt2pandas.py

    pyproject.toml

 

pyproject.toml

[project]
name = "dt2pandas"
description = "jmp.DataTable to pandas.DataFrame example"
authors = [
{ name = "Paul R. Nelson", email = "paul.nelson@jmp.com" }
]

version = "0.1"
dependencies = [ "pandas" ]

 

At which point you can do a

jmputils.jpip('install', '-e _my_path_to/dt2pandas')

 

 

View solution in original post

3 REPLIES 3
jthi
Super User


Re: Install and use local custom Python module

How do you manage them when you are not using JMP? Most likely you could utilize something similar when using JMP.

-Jarmo


Re: Install and use local custom Python module

JMP will just 'find it' if it is in the same directory as the launching .jsl or .py script.  There is an issue in JMP 18.0 if the launching script is .jsl, it doesn't find the .py import.  

 

It should work fine from both .jsl or .py scripts in 18.1+

 

The other way is to create a pyproject.toml file, put the script into a directory of the same name as the file and an appropriate pyproject.toml file.  This makes it an installable package which jpip can then install into the JMP site-packages/ location.  See Python.org's docs or many other tutorials on creating installable Python packages.  Such as: https://til.simonwillison.net/python/pyproject

 

 The code below is quick and dirty and probably doesn't follow python best practices.  I think there is usually an __init__.py file and __main__.py or main.py instead of the file matching the package directory...  But the toml file lets you specify lots if things including dependancies as show below.

 

dt2pandas/

    dt2pandas.py

    pyproject.toml

 

pyproject.toml

[project]
name = "dt2pandas"
description = "jmp.DataTable to pandas.DataFrame example"
authors = [
{ name = "Paul R. Nelson", email = "paul.nelson@jmp.com" }
]

version = "0.1"
dependencies = [ "pandas" ]

 

At which point you can do a

jmputils.jpip('install', '-e _my_path_to/dt2pandas')

 

 

robot
Level VI


Re: Install and use local custom Python module

Excellent, thanks Paul.