Soulflesh 1 Posted July 12, 2021 (edited) Hi, unfortunately it's not possible to compile PythonEngine.pas for Linux64 with Delphi 10.4. [DCC Fehler] PythonEngine.pas(198): E2003 Undeklarierter Bezeichner: 'PUCSChar' [DCC Fehler] PythonEngine.pas(199): E2007 Konstante oder Typenbezeichner erwartet [DCC Fehler] PythonEngine.pas(4396): E2010 Inkompatible Typen: 'Dynamic array' und 'UCS4String' Any ideas? Best regards Edited July 12, 2021 by Soulflesh Share this post Link to post
pyscripter 689 Posted July 12, 2021 (edited) There was a typo which is not fixed {$IFDEF POSIX} PWCharT = PUCS4Char; PPWCharT = PUCS4Char^; WCharTString = UCS4String; {$ELSE} Please try again with the latest. Please report back any further issues, since I have not tested with Linux recently. Edited July 12, 2021 by pyscripter Share this post Link to post
Soulflesh 1 Posted July 13, 2021 Hi pyscripter, Thank you. I have additionally changed the following lines and now I'm able to compile: 199 --> PPWCharT = ^PUCS4Char; 4396 --> WL := UnicodeStringToUCS4String(TempS); Best regards Share this post Link to post
pyscripter 689 Posted July 13, 2021 36 minutes ago, Soulflesh said: 4396 --> WL := UnicodeStringToUCS4String(TempS); Do you mean? WL[Ι] := UnicodeStringToUCS4String(TempS); Changes committed. Share this post Link to post
Soulflesh 1 Posted July 13, 2021 Unfortunately now I get a "range check" exception here: [PythonEngine.pas / Line 4219] if Assigned(Py_SetProgramName) and (ProgramName <> '') then Py_SetProgramName(PWCharT(FProgramName)); My "configuration" is: PythonEngine.UseLastKnownVersion := false; PythonEngine.DllPath := '/usr/lib/x86_64-linux-gnu'; PythonEngine.DllName := 'libpython3.9.so.1.0'; Any ideas? Best regards Share this post Link to post
Soulflesh 1 Posted July 13, 2021 The exception is raised in the UCS4StringToUnicodeString function. Called by function TPythonEngine.GetProgramName: UnicodeString; And FProgramName is "{...}" ??! Share this post Link to post
pyscripter 689 Posted July 13, 2021 (edited) FProgramName should have a lenght of 0 (empty string) unless you call SetProgramName. Could you please check whether UCS4StringToUnicodeString fails with an empty string? UCS4String is defined as an array of UCS4Char. Could this be a fix? function TPythonEngine.GetProgramName: UnicodeString; begin {$IFDEF POSIX} if Length(FProgramName) = 0 then Result := '' else Result := UCS4StringToUnicodeString(FProgramName); {$ELSE} Result := FProgramName; {$ENDIF} end; Edited July 13, 2021 by pyscripter Share this post Link to post
Soulflesh 1 Posted July 13, 2021 This raises an exception: SetLength(Test,0); Result := UCS4StringToUnicodeString(Test); Your suggested code has solved the problem! 😀 Python Scripts runs now on Linux (Ubuntu 18.04.5 LTS with Python 3.9.6). Best regards 1 Share this post Link to post
Soulflesh 1 Posted July 14, 2021 Hi pyscripter, Unfortunately a wrong character has crept into the code in the PythonEngine.pas in line 4396 for the "I": Best regards Share this post Link to post
pyscripter 689 Posted July 14, 2021 21 minutes ago, Soulflesh said: Unfortunately a wrong character Thanks.. It is now fixed. Share this post Link to post