dartpy icon indicating copy to clipboard operation
dartpy copied to clipboard

installing third party python packages

Open silverhairs opened this issue 3 years ago • 3 comments

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

silverhairs avatar Mar 08 '21 15:03 silverhairs

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.

TimWhiting avatar Mar 08 '21 16:03 TimWhiting

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.

AlzbetaHajna avatar Jan 08 '24 17:01 AlzbetaHajna

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

TimWhiting avatar Jan 08 '24 17:01 TimWhiting