Jump to content

Luca Pretti

Members
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Luca Pretti

    Using Python4Delphi library in a Windows service

    Now the Windows service starts correctly and keeps running but when I try to execute a script I get the following error: ImportError: Unable to import required dependencies: numpy: No module named 'numpy' pytz: No module named 'pytz' dateutil: No module named 'dateutil' The same exact code works perfectly when the application is compiled as a console. It looks like the Python engine is not able to resolve the path to base scripts when launched by a service. This is my registered path: PATH=C:\Program Files\Python313\Scripts\;C:\Program Files\Python313\;
  2. Luca Pretti

    Using Python4Delphi library in a Windows service

    You were right ! If I create the PythonEngine instance in ServiceExecute I do not get the access violation anymore. Thank you very much !
  3. Luca Pretti

    Using Python4Delphi library in a Windows service

    I managed to debug the service and I found that the ACCES VIOLATION is raised at line 5091 of the PhythonEngine.pas unit, "CheckError(False)". The problematic line of code of this procedure is the first (line 6398) : " PyException := PyErr_Occurred;"
  4. Luca Pretti

    Using Python4Delphi library in a Windows service

    I dropped the component on the service module and set AutoLoad to False. Then in the ServiceCreate event handler I do: PythonEngine.DLLName := 'python312.dll'; PythonEngine.DllPath := 'C:\Users\Luca\AppData\Local\Programs\Python\Python312\'; PythonEngine.RegVersion := '3.12'; PythonEngine.UseLastKnownVersion := False; PythonEngine.FatalAbort := False; PythonEngine.FatalMsgDlg := False; PythonEngine.LoadDll;
  5. Luca Pretti

    Using Python4Delphi library in a Windows service

    Yes, the library is loaded correctly, but as soon as the program calls ExecString the program crashes. In the Winows Application Event Viewer I find this error event : This is the code in the ServiceExecute event handler: while not terminated do begin ServiceThread.ProcessRequests(False); inc(LoopsCount); if LoopsCount > 100 then begin PythonEngine.ExecString('2*2'); LoopsCount := 0; end; sleep(100); end;
  6. I am trying to implement a Windows service to run some Python scripts in background. Is that possible ? As soon as I try to create a TPythonEngine instance with AutoLoad set to true the service hangs. If I create an instance with AutoLoad set to False the service starts correctly but as soon I try to call LoadDll the service hangs. Any help will be greatly appreciated.
×