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

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
jaysoifer
Is there a way to rollback a specific migration and only that one ("skipping" all the other ones)? Would mix ecto.rollback -v 2008090...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
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
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

Other popular topics Top

Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
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
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
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35953 110
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New

We're in Beta

About us Mission Statement