Giter Club home page Giter Club logo

python4delphi's Introduction

drawing

Python for Delphi (P4D) is a set of free components that wrap up the Python DLL into Delphi and Lazarus (FPC). They let you easily execute Python scripts, create new Python modules and new Python types. You can create Python extensions as DLLs and much more. P4D provides different levels of functionality:

  • Low-level access to the python API
  • High-level bi-directional interaction with Python
  • Access to Python objects using Delphi custom variants (VarPyth.pas)
  • Wrapping of Delphi objects for use in python scripts using RTTI (WrapDelphi.pas)
  • Creating python extension modules with Delphi classes and functions

P4D makes it very easy to use python as a scripting language for Delphi applications. It also comes with an extensive range of demos and tutorials.

How to use Python4Delphi

The best way to learn about how to use Python for Delphi is to try the extensive range of demos available. Also studying the unit tests for VarPyth and WrapDelphi can help understand what is possible with these two units.

Wiki topics

Learn about Python for Delphi

Support forum

Visit the support forum to ask questions and discuss P4D related issues.

License

The project is licensed under the MIT license.

python4delphi's People

Contributors

checkdigits avatar csevast avatar elminsterau avatar fostertoster avatar idanmiara avatar jimmckeeth avatar lmbelo avatar minguyen1984 avatar mrcsms avatar norayr avatar pigrecos avatar pyscripter avatar reiniernl avatar shaunroselt avatar wxinix avatar yashovardhansingh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

python4delphi's Issues

Error while import a python package called h5py

Good morning,
I try to use C++ demo20 to test the import of lib H5PY but I have the following message from console when I execute these lines;
"import os
import time
import copy
import numpy as np
np.set_printoptions(precision=6, threshold=20, suppress=True, linewidth=100)

import h5py"

Error message is:
Traceback (most recent call last):
File "", line 7, in
File "C:\Anaconda3\lib\site-packages\h5py_init_.py", line 33, in
from . import version
File "C:\Anaconda3\lib\site-packages\h5py\version.py", line 15, in
from . import h5 as _h5
File "h5py\h5.pyx", line 1, in init h5py.h5
ImportError: DLL load failed while importing defs: La procédure spécifiée est introuvable.

Any idea on how to fix it please?

Android installation fails to find the Python package

The current version of this package can't find the python package for android builds so android install never gets past this stage.

My original install under CE works OK - I guess an earlier version installed the package but doing a fresh install under D11.1 Trial results in python package not being found.

Also D11.2 wouldn't install anything other than Win32 when I tried that a few weeks ago (D11.1 is OK though)

Python and Skia don't mix

I'm not positive about the exact criteria yet

Basically imports with Skia fully enabled causes Skia to hit problem with floating point

Take anything with an import and add this to your dproj (after installing Skia of course) and everything will go badly wrong.

Masking the FPU exception doesn't seem to help

As I don't know which package is causing the issue this is posted here

uses
  Skia, Skia.FMX, , ....

begin
  GlobalUseSkia := True;
  GlobalUseSkiaRasterWhenAvailable := False;
.
.

Non-Windows FMX won't install on Community Edition

[Moved here from main repo]

The Multi-Installer just throws up a dialog box saying there's no install directory when run

Installing via Delphi from project group compilation fails as the non-Windows targets try to compile source that includes the Windows unit

The result of this is that no down-stream projects (Python Environments, Lightweight wrappers, P4D Data Sciences can be installed on non-Wondows targets either).

I will stress that this is observed using Delphi 10 Sydney Community Edition so if you have a 'Real' Delphi on system this may result in different experiences.

Suggested replication - use a clean Windows install and Delphi Community Edition, easiest way to achieve this without spare kit is to use a VMWare Player with fresh install of Win10 + Delphi Community then this try to install this and dependant libraries.

If resolution is found very clear documentation would help (I'd write it myself if I could get the stuff to install)

FMX Linux 64 compilation issue

This may be a problem with Delphi 11.1 Trail and FMXLinux Trial - won't know for sure until @jimmckeeth supplies a key

The FMX components of this package fail to compile under Linux as fmx and bindcompfmx can't be found by PythonFmx.dproj

Using WSL I searched for the bindcompfmx package and find it's missing under Linux but present for other FMX targets.

As I say, this may be a Trial issue (although Trial should be functional too really)

I was able to work around the issue by changing the dproj slightly causing implicit import warnings x 111 like this...

{$IFNDEF LINUX64}
fmx,
bindcompfmx,
{$ENDIF}

There is no Linux target assigned for PythonFmx so my first installation just skipped over it but this resuled in PythonGUIInputOutput not being found by my test project (which I tracked down to this cause)

After fixing this one everything else complained about newer version of PythonEngine so had to recompile all the other stuff as well - on the bright side the result was a working test project

Wont build under Delphi 11.2 (Trial)

[dcc64 Fatal Error] Vcl.PythonGUIInputOutput.pas(53): E2213 Bad packaged unit format: C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp\Python.dcp.PythonEngine - Expected version: 35.0, Windows Unicode(x64) Found version: 35.0, Windows Unicode(x86)

Works fine in 11.1 Trial + 10.4.2 CE

Compiling CameraPreviewDemo

Trying the CameraPreviewDemo results in pydistfinder.exe not found

Realising pydistfinder.exe is required I found and compiled it and now Definition.inc can't be found so I copy that from Source/Defenition as that's the only file named Definition.inc in the repo

Which gets me to

[DCC Error] MainForm.pas(276): E2250 There is no overloaded version of 'RequestPermissions' that can be called with these arguments
[DCC Error] MainForm.pas(288): E2250 There is no overloaded version of 'Synchronize' that can be called with these arguments
[DCC Error] MainForm.pas(304): E2250 There is no overloaded version of 'Synchronize' that can be called with these arguments
[DCC Error] MainForm.pas(323): E2250 There is no overloaded version of 'ShowMessage' that can be called with these arguments
[DCC Fatal Error] CameraPreviewDemo.dpr(6): F2063 Could not compile used unit 'MainForm.pas'

==== Full error text ====

dccaarm64 command line for "CameraPreviewDemo.dpr"
c:\program files (x86)\embarcadero\studio\22.0\bin\dccaarm64.exe -$O- --no-config -M -Q -TX.so -AGenerics.Collections=System.Generics.Collections;
Generics.Defaults=System.Generics.Defaults -DDEBUG;;FRAMEWORK_FMX -E.\Android64\Debug -I"c:\program files
(x86)\embarcadero\studio\22.0\lib\Android64\debug";D:\Delphi\11.2.1\P4DSuite\python4delphi\lib\Android64\Debug;
D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\lib\Android64\Release;D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\src\AddOn;
D:\Delphi\11.2.1\P4DSuite\Lightweight-Python-Wrappers\lib\Android64\Debug;"c:\program files (x86)\embarcadero\studio\22.0\lib\Android64\Release";
D:\Delphi\11.2.1\P4DSuite\python4delphi\lib\Android64\Release;C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp\Android64;
D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\lib\Android64\Release;D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\src\AddOn;
D:\Delphi\11.2.1\P4DSuite\Lightweight-Python-Wrappers\lib\Android64\Release;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source\FMX
-LEC:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\Android64 -LNC:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp\Android64
-NU.\Android64\Debug -NSSystem;Xml;Data;Datasnap;Web;Soap; -O"c:\program files (x86)\embarcadero\studio\22.0\lib\Android64\Release";
D:\Delphi\11.2.1\P4DSuite\python4delphi\lib\Android64\Release;C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp\Android64;
D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\lib\Android64\Release;D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\src\AddOn;
D:\Delphi\11.2.1\P4DSuite\Lightweight-Python-Wrappers\lib\Android64\Release;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source\FMX -R"c:\program files
(x86)\embarcadero\studio\22.0\lib\Android64\Release";D:\Delphi\11.2.1\P4DSuite\python4delphi\lib\Android64\Release;
C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp\Android64;D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\lib\Android64\Release;
D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\src\AddOn;D:\Delphi\11.2.1\P4DSuite\Lightweight-Python-Wrappers\lib\Android64\Release;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source\FMX -U"c:\program files
(x86)\embarcadero\studio\22.0\lib\Android64\debug";D:\Delphi\11.2.1\P4DSuite\python4delphi\lib\Android64\Debug;
D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\lib\Android64\Release;D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\src\AddOn;
D:\Delphi\11.2.1\P4DSuite\Lightweight-Python-Wrappers\lib\Android64\Debug;"c:\program files (x86)\embarcadero\studio\22.0\lib\Android64\Release";
D:\Delphi\11.2.1\P4DSuite\python4delphi\lib\Android64\Release;C:\Users\Public\Documents\Embarcadero\Studio\22.0\Dcp\Android64;
D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\lib\Android64\Release;D:\Delphi\11.2.1\P4DSuite\PythonEnviroments\src\AddOn;
D:\Delphi\11.2.1\P4DSuite\Lightweight-Python-Wrappers\lib\Android64\Release;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source;
C:\Users\simon\Documents\Embarcadero\Studio\22.0\CatalogRepository\Skia4Delphi-3.4.1\Source\FMX
--libpath:C:\Users\Public\Documents\Embarcadero\Studio\22.0\CatalogRepository\AndroidNDK-21-22.0.46141.0937\android-ndk-r21\sources\cxx-stl\llvm-libc++\libs\arm64-v8a;
C:\Users\Public\Documents\Embarcadero\Studio\22.0\CatalogRepository\AndroidNDK-21-22.0.46141.0937\android-ndk-r21\platforms\android-23\arch-arm64\usr\lib
--linker:C:\Users\Public\Documents\Embarcadero\Studio\22.0\CatalogRepository\AndroidNDK-21-22.0.46141.0937\android-ndk-r21\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\aarch64-linux-android\bin\ld.exe
-V -VN -NO.\Android64\Debug CameraPreviewDemo.dpr
[DCC Error] MainForm.pas(276): E2250 There is no overloaded version of 'RequestPermissions' that can be called with these arguments
[DCC Error] MainForm.pas(288): E2250 There is no overloaded version of 'Synchronize' that can be called with these arguments
[DCC Error] MainForm.pas(304): E2250 There is no overloaded version of 'Synchronize' that can be called with these arguments
[DCC Error] MainForm.pas(323): E2250 There is no overloaded version of 'ShowMessage' that can be called with these arguments
[DCC Fatal Error] CameraPreviewDemo.dpr(6): F2063 Could not compile used unit 'MainForm.pas'
Failed

Python Android third-party packages

Hi,

I'm trying to develop an FMX application for Android using Python in Delphi. I've been following your demo application named 'Mobile Controls' as an example. Currently, I can write Python code into a memo and get output from another memo. However, I haven't been able to install any third-party packages. I've reviewed your videos and documents but couldn't find a solution. For instance, I want to use the 'numpy' library in my application. How can I add this? I would greatly appreciate your assistance.

Note: I'm using Delphi 12.

Best regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.