Hello everyone,
I do have a strange error happening when using erlport and python.
** (ErlangError) Erlang error: {:python, :"builtins.ModuleNotFoundError", 'No module named \'cv2\'', [' File "/export/koko/koko/_build/prod/rel/koko/lib/face_recon2-0.1.0/priv/python_scripts/face_recon2.py", line 1, in <module>\n import cv2\n', ' File "/export/koko/koko/_build/prod/rel/koko/lib/erlport-0.10.1/priv/python3/erlport/erlang.py", line 225, in _incoming_call\n f = __import__(mod, {}, {}, [objects[0]])\n', ' File "/export/koko/koko/_build/prod/rel/koko/lib/erlport-0.10.1/priv/python3/erlport/erlang.py", line 233, in _call_with_error_handler\n function(*args)\n']}
** (EXIT) an exception was raised:
** (stop) exited in: GenServer.call(#PID<0.2634.0>, {:recon_faces, "/export/koko/uploads/post_processing/MTY0NzczMjU3NzY1Nw/screenshots"}, :infinity)
I do have cv2 installed with opencv-python, opencv-contrib-python, but it looks like it does not find it.
What is strange is… it’s working in dev, it’s working with MIX_ENV=prod mix phx.server, but not when starting the release.
Did I forgot to set some python environment variables?
I start the erlport process with…
@impl true
def init(_) do
path = Path.join([:code.priv_dir(:face_recon2), "python_scripts"])
with {:ok, pid} <- :python.start([{:python_path, to_charlist(path)}, {:python, 'python3'}]) do
Logger.info("[#{__MODULE__}] Started python worker #{inspect self()}")
{:ok, pid}
end
end
...
@impl true
def handle_call({:recon_faces, path}, _from, pid) do
result = case :python.call(pid, :face_recon2, :recon_faces, [path, training_set()]) do
{'ok', map_message} -> {:ok, sanitize(map_message)}
{'error', error} -> {:error, to_string(error)}
any -> {:error, "Unknown error #{inspect any}"}
end
{:reply, result, pid}
end
I know it’s very specific, but if someone can help me understand why the python3 cv2 library is not found, I’ll be very happy
Thanks for taking time