Hello,
I’m currently developing a JMP add-in that relies on embedded Python scripts.
At startup, the add-in installs the required Python packages (using a local wheel repository) before executing any Python code.
The issue I’m facing is that, when the add-in is launched for the first time, it sometimes fails to execute the embedded Python functions defined in the files submitted right after the package installation.
It looks like JMP continues executing the script before the PowerShell installation process has actually completed.
The error I get is that Python cannot find one of the functions defined in the two Python Submit File calls.
After the first successful installation, everything works fine (probably because the packages are already present and the scripts are then loaded properly).
How can I make sure that JMP waits until the PowerShell installation process is fully completed before running Python Submit File()?
Here’s the relevant part of my code:
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" );