Machine learning in Elixir

Good evening,
I am doing a machine learning application and unfortunately I can’t do it yet in Elixir (thank you for all your effort put in Nx:)). So, I decided to make a port (a bare port, not ErlPort) but I’m struggling with python envs.

Does anyone know how to launch a python program with a python environment activated in Elixir?

And for the people who deploy machine learning models in production, how do you do that?Thanks:)

Thanks! :smiley:

That’s an interesting question! Which however I don’t fully understand :smiley:
What do you mean exactly?

Sorry for the delay

I mean, when you are going to work on your project, you usually start activating your environment

source myproject_env/bin/activate

and then, you have access to all the dependencies your project needs


so the question is, can i activate my environment using a port?

pd: I know i can just install all the dependencies in the machine but I want to know if someone knows something about this:)
pd2: Also I want to know how is it do it in a professional environment.

thanks :slight_smile:

I have never tried it but I think that setting the environment variable PYTHONPATH should be enough.

If you’re using you can try

port ={:spawn, cmd}, [:binary, {:env, [{'PYTHONPATH', '/path/to/your/venv/Lib/site-packages'}]}])
1 Like

uuh, that sounds great

I made a mistake in my previous answer and I just corrected it. Try to use the PYTHONPATH and not PYTHONHOME variable.

1 Like

You may also find some goodness within @alvises blog here: Real-time Object Detection with Phoenix and Python


It works!!, at least it loads the packages:)

I am going to try it more this weekend
thanks :slight_smile:

Excellent post!! thank you, marked as solution too :slight_smile:

The forum only allow me to select one solution :cry: sorry