TimWhiting / dartpy

An experiment in embedding Python in Dart via dart ffi and the Python c-api
68 stars 10 forks source link

Does this work on mobile platforms currently? #8

Open Rickaym opened 1 year ago

TimWhiting commented 1 year ago

Good question. I have not tried. Other people have though I haven't heard from them whether they have gotten it working. Theoretically it should be possible on Android at least. It probably gets tricky with python libraries / python library paths.

NiallBunting commented 6 months ago

I tried running it on android and got:

Syncing files to device Android SDK built for x86... E/flutter ( 9357): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ProcessException: Permission denied E/flutter ( 9357): Command: python3.10-config --ldflags --embed E/flutter ( 9357): #0 _ProcessImpl._runAndWait (dart:io-patch/process_patch.dart:487:7) E/flutter ( 9357): #1 _runNonInteractiveProcessSync (dart:io-patch/process_patch.dart:632:18) E/flutter ( 9357): #2 Process.runSync (dart:io-patch/process_patch.dart:68:12) E/flutter ( 9357): #3 pythonDylib (package:dartpy/src/ffi/ffi.dart:31:24) E/flutter ( 9357): #4 _pyLib (package:dartpy/src/ffi/ffi.dart:22:43) E/flutter ( 9357): #5 _pyLib (package:dartpy/src/ffi/ffi.dart) E/flutter ( 9357): #6 dartpyc (package:dartpy/src/ffi/ffi.dart:121:56) E/flutter ( 9357): #7 matrix_test (package:cb/matrix.dart:19:3) E/flutter ( 9357): #8 main (package:cb/main.dart:8:3) E/flutter ( 9357): #9 _runMain. (dart:ui/hooks.dart:159:23) E/flutter ( 9357): #10 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:296:19) E/flutter ( 9357): #11 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12) E/flutter ( 9357):

TimWhiting commented 6 months ago

You would have to set pyLibLocation to the location where you put python's dynamic library. There are likely other environment variables / python setup you would have to do.

tot14883 commented 2 months ago

What is this error? this is my actual path.

Invalid argument(s): Failed to load dynamic library
'/Library/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib': dlopen failed: library
"/Library/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib" not found
TimWhiting commented 2 months ago

Just what the error says: that path does not exist on whatever device you are running the app on. (If you are running on iOS then you would need to make sure that path exists on the iOS device, not the macOS device you are developing on presumably).

tot14883 commented 2 months ago

This is the correct path. I checked on my iTerm. ![Uploading Screenshot 2567-02-17 at 08.58.19.png…]()

Nilesh-d commented 1 month ago

Im getting Unhandled Exception: ProcessException: Permission denied. by running this on android. Is it not compatible with mobile platforms?