简体   繁体   中英

Load Python modules in Elixir

I just started with Elixir and I want to run the Python programs from Elixir. I created an Elixir project using mix . I've added the required python files in priv/python3 folder and I am able to run the required Python program. But the problem is my Python application requires several libraries, ML models and Pandas Dataframe to be loaded at first. This takes 10-20 seconds. So every time I call the Python function from Elixir all these libraries, models and dataframes will be loaded and it takes much more time to run a simple function. Is there a way to load all the models and dataframes at first in Elixir and use them when Python functions are called instead of loading them every time?

Let me know if any one need more details on this. Thank you.

You should be able to do what you need using Erlport (which explicitly supports Python and Ruby).

http://erlport.org/docs/python.html

Not necessary but potentially helpful is also the Elixir wrapper at: https://github.com/fazibear/export

I would probably just call the Erlang version from Elixir.

Erlport should allow you to start the python code once as a Port and then run functions as needed. I think this could be a solution to your problem. (I notice it is old, but not I've typed it all out).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM