こんにちは、
現在、埋め込み Python スクリプトに依存する JMP アドインを開発しています。
起動時に、アドインは Python コードを実行する前に、必要な Python パッケージを (ローカル ホイール リポジトリを使用して) インストールします。
私が直面している問題は、アドインを初めて起動したときに、パッケージのインストール直後に送信されたファイルに定義されている埋め込み 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" );
Read Function("text")を使用するのも一つの選択肢です
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");