ErlPort: :python.start() - {:error, {:not_found, 'erlport/priv'}}


I’ve been trying to employ ErlPort for making Python calls. It works, more or less, yet only in iex. When I start my project via iex -S mix, iex> :python.start() is successful. The same call from inside the compiled executive results in the error above. Directory erlport/priv exists in the project deps directory, that’s all I can figure out. What am I missing?

How do you create your executable? Do you build using mix escript?

If yes, those do not include the priv folders as far as I remember.


$ mix

What am I supposed to do?

no use an escript, but build a release or use mix run

Thanks! What does “build a release” mean? My project is a script, meant to be run from any directory.

“Build a release” means to use distillery or similar tools to build a self contained release. You can’t use those as scripts though.

If you want to build an escript, you can’t depend on packages that use their priv folder. So you probably need to find another way to talk to your python parts.

You mean, I can’t make a single self-contained file? If so, is it possible to make it callable from /usr/local/bin at least? I hope it is.

Well you ‘can’ by baking in the priv file contents into the module data directly and making sure the libraries you use do the same. Still though, it seems weird to make a single-script-runner in Elixir, the BEAM is designed for long running servers, not for something like tool scripts (where a shell script or python would generally be better).

There is nothing like Python for shell scripting :grinning: . I’ve been just researching in the field, whether the ride is moderately bumpy or downright ugly and impracticable. It’s moderately bumpy, I’m happy to tell urbi et orbi.

I also suspect that if you really need both Elixir and Python libraries in one app, you’d be better off making it an Elixir application.

Sadly Python has a lot of libraries that Elixir both does not have and would be an intense effort to port, so such things are fairly necessary from the Elixir ecosystem at times. ^.^;