kokolegorille
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
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
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
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
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
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #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)
kartheek
Did you try setting
PYTHONPATHenv variable?If it is working in one config and not working in other - you can check search path for modules:
If you can diff sys.path in release and dev, may be you can find answer of what is missing?
kokolegorille
Thank You for your help, I will try and report.
Could You tell me more about this PYTHONPATH? For sure I did not use it
kartheek
Python searches for modules in following places:
When using virtual environments -
source <venv>/bin/activateit adds<venv>/lib/python<version>/site-packagesfolder to the search path.Additional paths can be added using PYTHONPATH. Erlport also injects PYTHONPATH if it is set.
I feel you will find answer in diff from sys.path in dev and release environments.
It is unable to resolve cv2 module - mostly it has something to do with module search path.
kokolegorille
Thank You,
I have found the path… unfortunately, I cannot test it yet, because someone is working on the site.
But it looks this should solve the problem
kokolegorille
I updated the systemd script that start my application to include all path found with sys.path.
And now it works
Thank You very much
kartheek
You are welcome. Memories from the past - it was hell supporting python2 and python3 in production.
Just curious - you are using virtualenv in production ?
kokolegorille
No I don’t, I use one vm per apps, with/without Python.
If I had to share multiple Python environment per vm, I would use virtualenv.
But I am using it on my development machine
kartheek
virtualenv is also used to isolate the app from changes in system dependencies and upgrades in per vm machines - to pin down to a python version and pip dependencies.
Things evolve rapidly - don’t how people are solving this. Luckily I am out of python deployments from a couple of years.
Ayoush
can you share your env file since I am facing the same issue but I don’t know what to do as in my sys path I do have python
:/Library/PostgreSQL/16/bin:/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/Current/bin
but everytime I run :python.start it simply throws an error :-
{:error, :python_not_found}
So I created a virtual environment and then activated and then tried and then it works so I am pretty sure its something related to path. I tried this also :-
Again I don’t want to set the path this manner
ziinc
I would suggest using asdf or poetry for python management as they will handle the shims