你好,
我目前正在开发一个依赖于嵌入式 Python 脚本的 JMP 插件。
在启动时,插件会在执行任何 Python 代码之前安装所需的 Python 包(使用本地 wheel 存储库)。
我面临的问题是,当第一次启动该插件时,它有时无法执行包安装后立即提交的文件中定义的嵌入式 Python 函数。
It looks like JMP continues executing the script 在 PowerShell 安装过程实际完成之前.
The error I get is that Python cannot find one of the functions defined in the two Python Submit File calls.
第一次成功安装后,一切运行正常(可能是因为软件包已经存在并且脚本已正确加载)。
How can I make sure that JMP waits until the PowerShell installation process is fully completed before running Python Submit File()?
这是我的代码的相关部分:
strPathjpip = dest_path || "\jpip.bat";
If( !File Exists( strPathjpip ),
Python Send( dest_path );
Python Submit( "
import jmp
import jmputils
jmputils.create_jpip(dest_path)
" );
);
// Build command to run
cmd = Eval Insert( "\[& "^strPathjpip^" install --no-index --find-links "^strPathPythonLibs^" numpy pandas scipy]\" );
Eval( Eval Expr( commands = {Expr( cmd )} ) );
icommand = 0;
// Use Run Program to execute the script
rp = Run Program(
Executable( "PowerShell.exe" ),
ReadFunction( Function( {this}, Write( this << Read ) ) ),
WriteFunction(
Function( {this},
icommand++;
If( icommand <= N Items( commands ),
this << Write( commands[icommand] ),
this << WriteEOF
);
)
)
);
// Include Python scripts
Python Submit File( strPathAddin || "include/PYTHON/exttolint.py" );
Python Submit File( strPathAddin || "include/PYTHON/normtolint.py" );
使用读取函数(“文本”)是一种选择
Names Default To Here(1);
RP = Run Program(
Executable("PING.EXE"/*path probably not needed*/ ),
Options({"-n 5", "localhost"}),
ReadFunction("text")
);
Show(RP);
Write("\!NDONE");