Einzelnen Beitrag anzeigen

mmw

Registriert seit: 10. Sep 2019
Ort: OWL
322 Beiträge
 
Delphi 11 Alexandria
 
#16

AW: Python im Delphi ausführen (geht nicht)

  Alt 24. Jan 2021, 13:58
hallo,
ich hab's jetzt so gelöst. (Bemerkung: Ich benutze eine p4d-version von Mitte 2020, bei der aktuellen scheint sich was geändert zu haben)

in der Procedure

procedure TPythonEngine.Initialize; ausdokumentiert
// raise Exception.Create('There is already one instance of TPythonEngine running' );

den Code eingefügt.
Delphi-Quellcode:
if Assigned(gPythonEngine) then begin
   gPythonEngine := Self;
   CheckRegistry;
   FInitialized := True;
   FIORedirected := False;
   InitSysPath;
   SetProgramArgs;
   GetTimeStructType;
   GetDateTimeTypes;

if RedirectIO and Assigned(FIO) then
    DoRedirectIO;

for i := 0 to ClientCount - 1 do
    with Clients[i] do
      if not Initialized then
        Initialize;
 if InitScript.Count > 0 then
    ExecStrings( InitScript );
  if Assigned(FOnAfterInit) then
    FOnAfterInit(Self);
  exit;
end;

Delphi-Quellcode:
procedure TForm1.FormActivate(Sender: TObject);


begin
    PythonEngine1.LoadDll;
end;
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);

begin
    PythonEngine1.DllName:='python38.dll';
    PythonEngine1.DllPath:='d:\delphi10';
    edDllPath.Text:=PythonEngine1.DllPath;
    edDllName.text:=PythonEngine1.DllName;
end;
bis jetzt funktioniert's. Ist natürlich nur für den persönlichen Gebrauch gedacht und auf eigene Verantwortung.

Gruß

Geändert von mmw (24. Jan 2021 um 18:31 Uhr)
  Mit Zitat antworten Zitat