Jump to content
Sign in to follow this  
FranzB

GetRegisteredPythonVersions for LINUX

Recommended Posts

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
  FMX.Controls.Presentation, FMX.ScrollBox, FMX.Memo, FMX.StdCtrls,
  System.SyncObjs, FMX.Memo.Types, FMX.ListBox, System.IniFiles,
  PythonEngine, PythonVersions;





var
  PyVersion: TPythonVersion;
begin

  FPyVersions := GetRegisteredPythonVersions;
  for PyVersion in FPyVersions do
    cbb_Pyversions.Items.Add(PyVersion.DisplayName);
  if cbb_Pyversions.Items.Count > 0 then
  begin
    cbb_Pyversions.ItemIndex := 0;
  end;
end;

 

I failed to compile above code for LINUX OS, is there any workaround  in the UNIX platform ?

 

 

Share this post


Link to post

The PythonVersions unit is of little value in Linux, where there is no Registry and no registered Python versions.  You need to manually provide the DLLName and DLLPath.

 

You can use some code that searches possible file locations.  For example in the Mac you can do, something like:

{$ifdef MACOS}

for N:= 5 to 9 do begin

  S:= Format('/Library/Frameworks/Python.framework/Versions/3.%d/lib/libpython3.%d.dylib', [N, N]);

  if FileExists(S)

    then exit(S);

end;

{$endif}

 

In Debian Linux you can search for file locations such as:

/usr/lib/x86_64-linux-gnu/libpython3.7m.so
/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1
/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0

 

but it may vary by python distribution.

  • Like 1

Share this post


Link to post
Posted (edited)

what is the  correct path setting for  using python4delphi with UBUNTU ?

can I get a parameter recommendation 

 

Edited by FranzB

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×