TimWhiting / dartpy

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

installing third party python packages #1

Open silverhairs opened 3 years ago

silverhairs commented 3 years ago

Is it possible to work with 3rd party python packages? Like requests, Pillow, etc.

TimWhiting commented 3 years ago

Yes this should be possible. Be aware that this is a very low level API and has only a few helper methods to assist in working with python interop for basic primitives (String, int, double, etc). It is also a side project of mine, and not a primary focus. Feel free to contribute examples helper methods etc...

Python objects with buffered representations (numpy arrays, etc) I have not added higher level support, but it should be feasible.

In order to learn more about the API this exposes see the python C api documentation which is what I wrap using dart:ffi.

Except for my helper methods, you have to be pretty explicit about reference counting any objects you hold a reference to in order to help python know when to garbage collect.

AlzbetaHajna commented 4 months ago

Thank your work on this project!

I encounter an issue with not recognizing imported packages. I call import openpyxl in my flutter app. Then I get an error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'openpyxl'

Is this expected behaviour? Am I using it wrong? Or is the package openpyxl too high level for this package?

Thank you for any response.

TimWhiting commented 4 months ago

You would need to install openpyxl on the machine where the flutter app runs, and make sure the PYTHONPATH is set correctly.