Embarcadero/PythonEnvironments

P4D in android platform module pip

Walid-alg opened this issue · 7 comments

I have an issue with installing any external Python library; the pip module does not work on the Android platform. Is there a solution for this?

I try import pip module,
The message error is
"ModuleNotFoundError :No module named 'pip'"

https://en.delphipraxis.net/uploads/monthly_2024_10/Screenshot_20241001-194724.jpg.897cd6975d33ef829fe5d280707834d0.jpg
The module pip is working on fmx Windows plate-forme but not work in android platform

Thank you

lmbelo commented

Hello @Walid-alg, you must install pip before using it. There are two different components you can choose to install Pip: "GetPip" and "EnsurePip". You can find them alongside other PythonEnvironment components. Have in mind that non-pure Python packages won't be available to be installed using Pip.

bandicam.2024-10-12.20-30-06-265.mp4
SVID_20241013_044558_1.mp4

I have done this, but the PyTorch library was not downloaded, and also the code import pip module did not work.

I try install PyTorch library by code, I have this error :

SVID_20241013_194440_1.mp4
SVID_20241014_073407_1.mp4
lmbelo commented

PyTorch can't be installed from PIP on Android as there's no distribution. You must compile Torch for Android by yourself and distribute the result of your compilation alongside your app.

PyTorch can't be installed from PIP on Android as there's no distribution. You must compile Torch for Android by yourself and distribute the result of your compilation alongside your app.

Thank you. I want to understand the role of general packages for Delphi, including MoviePy and others, such as the data science ecosystem libraries like numpy, pandas, etc. Do I need to compile each library, and what is the role of addOnGetPip?
Again, I appreciate it and send my regards to you.

lmbelo commented

@Walid-alg,

As I said, many packages distributed on PIP have not Android support, specially extension modules. Extension modules are C/C++ packages compiled against Python's interpreter. When you install this sort of packages, they are automatically compiled during installation, but this is not the case for Android. If you need to install a Python extension module on Android, you need to compile it agains a Python bundle compiled with Androids's toolchain, and then distribute it alongside your application.
We provide Python bundles for Android and also iOS. You can use them to compile your extension modules.

Note: This might be a complex task. Many extension modules like TensorFlow provide a guide and a version of the library to compile for Android.

you need to compile it agains a Python bundle compiled with Androids's toolchain, and then distribute it alongside your application.
How ti do it ?
What is the method? Thank you.