DennisTW 1 Posted July 29, 2022 Since I need to run Python4Delphi in a separate thread. I first try to modify demo01 of Python4Delphi to create TPythonEngine and TPythonGUIInputOutput at run time instead of design time. procedure TForm1.FormCreate(Sender: TObject); begin PythonGUIInputOutput1:= TPythonGUIInputOutput.Create(self); PythonGUIInputOutput1.Name := 'PythonGUIInputOutput1'; PythonGUIInputOutput1.Output := Memo2; PythonEngine1 := TPythonEngine.Create(self); PythonEngine1.Name := 'PythonEngine1'; PythonEngine1.IO := PythonGUIInputOutput1; end; However, when I run the demo01.exe now, it pops up the error "Python is not properly initialized"!!! How do fix it? My eventual goal is to create TPythonEngine , TPythonGUIInputOutput and other python4delphi components in a separate thread at run time, so as to make python run in its own thread. Please kindly help. Share this post Link to post
pyscripter 689 Posted July 29, 2022 You are not calling PythonEngine1.Load. Demo34 shows how to load a python engine dynamically, but please note that this is very tricky and things can go wrong. Share this post Link to post
DennisTW 1 Posted July 29, 2022 Tried. There is no method named " PythonEngine1.Load", but I found PythonEngine1.LoadDll and it worked. Thanks. Share this post Link to post