Tormenator1
I’m still learning Elixir,and am making a basic elixir program to call a function from a python program. I am attempting to use erlport to do so. However, in the code below Erlport is undefined. I don’t see what could be causing it.
defmodule RarFile do
@moduledoc """
Documentation for `RarFile`.
"""
@doc """
Hello world.
## Examples
iex> RarFile.hello()
:world
"""
def extractor(filepath) do
{:ok, pid} = :erlport.open_port({:spawn, "python"}, [:binary, :stream, packet: 4])
end
end
Here is the mix.exs file that I’m using.
defmodule RarFile.MixProject do
use Mix.Project
def project do
[
app: :rar_file,
version: "0.1.0",
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:erlport, "~> 0.10"}
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
]
end
end
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
hi @Tormenator1 please always include a copy and paste of the exact error when asking about an error.
In glancing at the docs found here ErlPort - Python documentation the function you are trying to use is never mentioned, are you sure you’re calling a function that exists?
kokolegorille
You are confusing erlport eith Elixir Port, they are not the same…
You should do something like this example…
al2o3cr
FWIW,
open_portis a built-in Erlang function.Erlport provides wrappers to open ports to Python and Ruby executables, you should use one of those if that’s what you’re looking to do.
Tormenator1
I have multiple python environments on the development machine. How would I select a specific one?
Also, when enetering the first line of code you provided I get this error.
(SyntaxError) keyword argument must be followed by space after: python:
|
18 | {ok, PythonInstance1} = python:start()
| ^
Stacktrace:
│ (elixir 1.14.4) lib/kernel/parallel_compiler.ex:340: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/7
kokolegorille
No idea how is your setup…
But starting my release with Systemd, I can pass Python environment variables.
kokolegorille
That is not Elixir code, but Erlang, it should be…
… in Elixir. And beware with the strings, they are not really the same between Elixir and Erlang
Tormenator1
I am using this exact line when i get the error above.
Elixir thinks that this is a syntax error.
I get a similar error when I try this line from the language docs
Why exactly would this be happening?
kokolegorille
Erlport is an Erlang package, so the doc is written in Erlang…
I advise You to read this page, if You want to translate from Erlang to Elixir
kokolegorille
No, I did not provide code written in Erlang
Tormenator1
So the python file is called handler.py and the function I am calling is called hey. It accepts 1 string parameter.
How would I call that function in this code. I’m unclear about what is meant to be passed into the call function in terms of the module parameter?