Installation - Embarcadero/python4delphi GitHub Wiki

Delphi

You can install Python4Delphi into your Delphi IDE using MultiInstaller (Delphi Sydney or later) or by following the below guide:

Manual Installation

For Delphi Sydney and later:

  • Clone or download and unzip the GitHub repository into a directory (e.g., path\to\python4delphi). Cloning is preferable, since you can then easily update the code.

  • Start RAD Studio.

  • Add the following source subdirectories to the IDE's library path for the target platform you plan to use.

    • path\to\python4delphi\Source
    • path\to\python4delphi\Source\vcl
    • path\to\python4delphi\Source\vcl

    For example, we want to add the above paths to the Windows 64-bit target platform. Then, on the Delphi IDE;

    • Goto Tools > Options > Language > Delphi > Library
    • Choose the Windows 64-bit on the "Selected Platform" dropdown
    • Now we can add those above-listed paths to the Library Path list
    • Note: Exclusively on Delphi 11.2 and for Windows 64-bit platform, we need to add "\$(Platform)" to the "$(BDSCOMMONDIR)\Dcp" path. So the final Library path modifies to: $(BDSCOMMONDIR)\Dcp\$(Platform). This sets up the correct dcp path for Win64. If you're using a Delphi version other than 11.2, you don't need to modify this path for Win64. This issue is addressed here: https://github.com/Embarcadero/python4delphi/issues/36

    • Click on OK and Save to finish adding the paths to the Library path list

  • On the IDE, open the "P4DComponentSuite" project group by going to File > Open Project and browse for path\to\python4delphi\Packages\Delphi\P4DComponentSuite.groupproj file.

  • On the top-right side of the IDE, you'll find the Projects dock where you can see the currently opened P4DComponentSuite project group.

  • Now, you need to build P4D for the target OS platform of your choice and then install design time components to your IDE. The buttons to set the Active Platform and the Active Configuration are shown below:

  • Right click on the P4DComponentSuite and you'll get a context menu as shown above. Click on Build All option to build and generate all of the compiled unit (dcu) files. This step creates a lib folder in the root directory at path\to\python4delphi.
  • Add the path\to\python4delphi\lib\Win64\Release to the Library Path as we've done before. This step will make sure we don't recompile P4D when it's used as a dependency for other projects.

  • Now, choose the Debug active configuration mode Build All which creates a path\to\python4delphi\lib\Win64\Debug folder. Add this path to the Debug DCU Path list using the button mentioned in the first figure above.

  • Similarly, repeat the above steps to other Target Platforms of your choice.

  • Then install the dclPython, dclPythonVcl, and dclPythonFmx design-time packages by multi-selecting them as shown below:

For Delphi earlier versions:

  1. Clone or download and unzip the GitHub repository into a directory (e.g., D:\Components\P4D). Cloning is preferable, since you can then easily update the code.

  2. Start RAD Studio.

  3. Add the source subdirectory (e.g., D:\Components\P4D\Source and D:\Components\P4D\Source\vcl) to the IDE's library path for the targets you are planning to use.

  4. Open and install the Python4Delphi package. It can be found under Packages\Delphi\Delphi 10.3- directory.

Note: For Delphi Sydney and later, packages are separated into run-time and design-time. For Delphi earlier versions, a single package is available as run-time and design-time.

C++Builder

See the blog post by David Intersimone

Lazarus (FPC)

The Lazarus Python4Delphi package can be found in the Packages/FPC directory. Install it in the standard way.