- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Install and use local custom Python module
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Install and use local custom Python module
Excellent, thanks Paul.