PythonEnvironments icon indicating copy to clipboard operation
PythonEnvironments copied to clipboard

P4D in android platform module pip

Open Walid-alg opened this issue 1 year ago • 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

Walid-alg avatar Oct 12 '24 07:10 Walid-alg

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.

lmbelo avatar Oct 12 '24 20:10 lmbelo

https://github.com/user-attachments/assets/8331fa0a-d910-428a-9eea-85a7132a923a

https://github.com/user-attachments/assets/1f6b4e15-f5a9-4ef5-a8c4-1e63998e322f

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

Walid-alg avatar Oct 13 '24 03:10 Walid-alg

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

https://github.com/user-attachments/assets/4d41e173-a57e-4bb1-8e97-ad418a48e68a

https://github.com/user-attachments/assets/db755652-a625-4ff9-88c6-01e5ce57842d

Walid-alg avatar Oct 13 '24 18:10 Walid-alg

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.

lmbelo avatar Oct 15 '24 13:10 lmbelo

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.

Walid-alg avatar Oct 15 '24 17:10 Walid-alg

@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.

lmbelo avatar Oct 21 '24 14:10 lmbelo

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.

Walid-alg avatar Oct 21 '24 16:10 Walid-alg