james_p_d

james_p_d

Calling Elixir function from Python with pyrlang

Hello all,

I’ve recently been playing around with both Erlang and Elixir and wished to create a few apps for my Github with them, both of which required a small UI. For the Erlang project I managed to get a Java Swing program to call functions running on an Erlang server without any issues. For the Elixir project I’d like to use Python.

I came across ‘pyrlang’ and was able to run through a couple of examples of interacting with an Erlang server through Python, but I’m not finding much in the way of information regarding calling Elixir.

If anyone has any experience with pyrlang, can you tell me what I’d need to do to pass a couple of variables to an Elixir function, and retrieve the result?

# To start server: werl -name erl@127.0.0.1 -setcookie COOKIE -env ERL_LIBS "C:\Program Files (x86)\Elixir\lib" -user Elixir.IEx.CLI -extra --no-halt
# To compile: c("library.ex")
# To test: Lib.add_numbers(3, 4)

defmodule Lib do
    def add_numbers(a, b) do
        a + b
    end
end

Most Liked

samrose

samrose

In case anyone comes across this via searching for Pyrlang and Elixir examples:

The documentation, and code examples now cover elixir

There are 2 make commands for the python and elixir nodes Pyrlang/Makefile at master · Pyrlang/Pyrlang · GitHub

plus, there are Examples! — Pyrlang 1.0 documentation instructions and code
Pyrlang/examples/elixir at master · Pyrlang/Pyrlang · GitHub

Maxximiliann

Maxximiliann

Hello friend and welcome to the forum. :slight_smile:

Being in a similar boat, I’ve found the step-by-step articles below to be very helpful in devising a solution using ErlPort, an Elixir library:

  1. https://medium.com/hackernoon/mixing-python-with-elixir-7a2b7ac6696
  2. https://medium.com/hackernoon/mixing-python-with-elixir-ii-async-e8586f9b2d53
  3. https://medium.com/hackernoon/calling-python-from-elixir-erlport-vs-thrift-be75073b6536

Perhaps they can, at the very least, point you in the right direction? :slight_smile:

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement