AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Werkzeuge Python im Delphi ausführen (geht nicht)
Thema durchsuchen
Ansicht
Themen-Optionen

Python im Delphi ausführen (geht nicht)

Ein Thema von himitsu · begonnen am 21. Jan 2021 · letzter Beitrag vom 20. Dez 2022
 
TiGü

Registriert seit: 6. Apr 2011
Ort: Berlin
3.073 Beiträge
 
Delphi 10.4 Sydney
 
#8

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

  Alt 22. Jan 2021, 07:39
Nur vom reinen Doku lesen sind mir die folgenden Punkte aufgefallen.
Ich habe sie im Quelltextschnipsel ergänzt und mit Kommentar versehen.
https://github.com/pyscripter/python.../FindingPython

Zitat:
If you want to use a specific unregistered version set the following properties
DLLName e.g. python38.dll
RegVersion e.g 3.8
Set UseLastKnownVerion property to False
Set the DLLPath to the path where the DLL is located
Set the AutoLoad property to False
In your FormCreate event handler of the MainForm or in another suitable place run the following assuming that PythonEngine is the name of the component
PythonEngine.SetPythonHome('your python installation directory')
PythonEngine.LoadDLL
Delphi-Quellcode:
procedure TForm9.BtExecClick(Sender: TObject);
begin
  if not PythonEngine1.IsHandleValid then begin
    PythonEngine1.DllPath := EdDllPath.Text; // hier ist die Bitness sichergestellt? Manchmal hat man ja Tomaten auf den Augen und versucht stundenlang eine 64-Bit DLL in einem 32-Bit Prozess zu laden
    PythonEngine1.DllName := EdDllName.Text;
    PythonEngine1.RegVersion := ''; // fehlt, da muss sowas wie 3.9 rein
    PythonEngine1.UseLastKnownVersion := False;
    PythonEngine1.AutoLoad := False // hat gefehlt
    PythonEngine1.SetPythonHome('your python installation directory'); // hat gefehlt (ggf. Inhalt aus PythonEngine1.DllPath probieren)
    MaskFPUExceptions(True); // hat gefehlt, vielleicht hilfreich
    PythonEngine1.LoadDll;
  end;

  if not PythonEngine1.Initialized then begin
    PythonEngine1.InitScript.Text := EdGlobalScript.Text;
    PythonEngine1.Initialize;
  end;
...
end;

Geändert von TiGü (22. Jan 2021 um 07:42 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:53 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz