开发人员教程:JMP 18 中的新 Python 集成和脚本编写功能该视频包括参加 2024 年 3 月 21 日现场网络研讨会的与会者的问答。时间为 25:36-50:39 和 01:00:21 下面提供了一些问答的摘要。如需完整答案,请考虑查看视频中的问答。
自动化和脚本编写回复:开发人员教程:JMP 18 中的新 Python 集成和脚本编写功能我想澄清一下这个问题的回答:
问:这是否意味着 JMP 无法使用其他版本的 Python?
JMP 18 将仅利用已安装的嵌入式 Python 3.11。用于选择 Python 安装的 Python Init() 和 Python Connect() 参数均已弃用,并且这些参数被忽略。
JMP 18 的 Python 是一个隔离环境,因此它不会(不应该)与系统上的其他 Python 安装发生冲突。没有什么可以阻止您利用现有的 Python 管道。您可以使用 JMP 的 Python 从 JMP 中获取数据,然后将数据移交给现有的管道。
回复:开发人员教程:JMP 18 中的新 Python 集成和脚本编写功能
@gail_massari写道:
问:如果我想在不同的 Python 环境中从 jupyter Notebook 访问 JMP 数据表,“import 'JMP”指令仍然有效吗?
答:没有。
“相同的 Python 环境”怎么样 - 是否可以将 Spyder 或 Visual Studio 代码编辑器等 Python IDE 链接到 JMP Python 安装?
拥有 IDE 的所有 Python 编程功能 + 能够
import 'JMP'
回复:开发人员教程:JMP 18 中的新 Python 集成和脚本编写功能import jmp语句只能在 JMP 本身内部起作用。
它不是作为共享库或 Python 脚本实现的,从 Python 到 JMP 功能的桥梁是 JMP 可执行文件本身内部的 C++ 代码。
回复:开发人员教程:JMP 18 中的新 Python 集成和脚本编写功能将带有图像的表格发送到 Python 时,是否可以从 Python 内部访问图像?
回复:开发人员教程:JMP 18 中的新 Python 集成和脚本功能# getColImage.py
#
# Description:
# Get a picture from an image column using Python
# JMP 18 only supports numeric and character column types for transfer
# but the value can be grabbed via JSL, and passed to Python as a string
# in the meantime. The Python code will need to trim off the
# New Image( Char To Blob()) and decode the image back to binary.
import jmp
dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class Families.jmp')
jmp.run_jsl('''
Names Default to Here(1);
dt = Current Data Table();
img = dt:picture[1]; // get the picture
img_str = char(img); // make it a string
Python Send(img_str); // send Python the string
''')
# print the object's JSL representation
# which is text encoding of the binary, a description of the
# encoding and image format type.
print(img_str)
输出:
新图像(Char 到 Blob(“1iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAYAAABxLuK ...
VORK5CYII=", "base64compressed" ), "png")
从 Python 方面,您需要解析出 Blob 字符串、压缩方法和格式,将图像从文本解码为二进制。
但是,一种替代的、可能更好的方法是在列上使用 << Get Pixels("rgba"); 来获取通过 Python Send() 支持的 4 元素矩阵列表。
更新了 getColImage.py
# getColImage.py
#
# Description:
# Get a picture from an image column using Python
# JMP 18 only supports numeric and character column types for transfer
# but the value can be grabbed via JSL, and passed to Python as a string
# in the meantime. The Python code will need to trim off the
# New Image( Char To Blob()) and decode the image back to binary.
#
# Alternatively use << Get Pixels("rgba"); to get a list of matricies
# which is passable from JSL to Python using Python Send();
#
import jmp
dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class Families.jmp')
jmp.run_jsl('''
Names Default to Here(1);
dt = Current Data Table();
img = dt:picture[1]; // get the picture
img_str = char(img); // make it a string
Python Send(img_str); // send Python the string
asRGBA = { r, g, b, a} = dt:picture[1] << Get Pixels("rgba");
Python Send(asRGBA);
''')
# print the object's JSL representation
# which is text encoding of the binary, a description of the
# encoding and image format type.
print(img_str)
print(asRGBA)
回复:开发人员教程:JMP 18 中的新 Python 集成和脚本功能帖子的前几行在某处被剪掉了。
不,无法直接使用 JMP 18 中的 Python 集成,但可以使用 JSL 来解决。
JMP 18 的重点是字符和数字列。对数据表的全面支持是当前正在进行的开发。