Jump to content
Sign in to follow this  
Walid Alg

P4D Android external Python library

Recommended Posts

I want to integrate Python libraries into an Android application in a Delphi environment. In general, to run a Python environment in an Android application, the environment must first be embedded and loaded from within Delphi by selecting Python and the version type. Then, it is eventually integrated with the application and appears in the form of an SO file.

 

What I am trying to do is figure out how to install any external Python library and run it in an Android application using Delphi.

 

I tried installing the MoviePy library through this link: https://github.com/Embarcadero/PythonPackages4Delphi/tree/main/src/MoviePy but it didn’t work. I also tried the attached project: https://github.com/Embarcadero/P4D-Data-Sciences/tree/main/samples/InstallAndImport which includes the PyTorch library. Both have the properties autoImport, autoInstall set to true, and the MoviePy and PyTorch components are set up by default as I stated earlier, with the addition of pythonEngine and pyEmbeddedEnvironment.

 

But neither worked.

 

The problem is the same: the same message appears, "no module named pip".

 

which is that when executing the isImported function, it returns the value false.

1.png

2.png

3.png

Screenshot_20241004-100039.jpg

Share this post


Link to post
Posted (edited)
15 hours ago, pyscripter said:

As I said, I have no experience of using these components.  But if you look at P4D-Data-Sciences/demos/PyTorch/PyTorchTimeSequencePrediction/MainForm.fmx at 551db5923fad9a9e8384169233dd64ddf9f87d12 · Embarcadero/P4D-Data-Sciences (github.com) you will see that a PythonEnvironments addon EnsurePip is used.

Pip is defualt setting, other is corda lib or.. I forget his name. 

I have posted this in several forums and communities that focus on Delphi, but I haven't found any answers regarding the use of P4D in the Android environment, let alone a solution to the problem. The only person who has responded to me on this topic so far is you.

 

Edited by Walid Alg

Share this post


Link to post
17 hours ago, pyscripter said:

As I said, I have no experience of using these components.  But if you look at P4D-Data-Sciences/demos/PyTorch/PyTorchTimeSequencePrediction/MainForm.fmx at 551db5923fad9a9e8384169233dd64ddf9f87d12 · Embarcadero/P4D-Data-Sciences (github.com) you will see that a PythonEnvironments addon EnsurePip is used.

pyEmbeddedResEnvironment310 is available in any library, thank you

Share this post


Link to post

It works, I don't know why, but after reinstalling the Python library for Windows from the official website, the latest version, I found the application in Delphi working and installing external libraries like PyTorch inside Delphi. Additionally, the function isImported returns true.

Now my question is, on Android, I tried the same application that works on Windows, but it didn’t install the PyTorch library, for example. In the settings, ManagerKind = pip / conda.

Using pip on Windows works to install the library, but conda doesn't work for installing the library.

I tried both pip and conda on Android, but neither worked. Can you help with this?

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  

×