你好,
我目前正在開發一個依賴嵌入式 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");