dlopen() error MacOS Monterey M1 ARM

On a Mac Mini M1 (ARM chip) with MacOS Monterey fails:
Traceback (most recent call last):
File “/opt/homebrew/bin/”, line 38, in
from MAVProxy.modules.lib import rline
File “/opt/homebrew/lib/python3.9/site-packages/MAVProxy/modules/lib/”, line 13, in
import gnureadline as readline
ImportError: dlopen(/opt/homebrew/lib/python3.9/sitepackages/, 0x0002): symbol not found in flat namespace ‘_emacs_meta_keymap’

However, calling the interpreter on first line, both imports work:
$ head -1 ‘which’
$ /opt/homebrew/opt/python@3.9/bin/python3.9
Python 3.9.10 (main, Jan 15 2022, 11:40:53)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from MAVProxy.modules.lib import rline
>>> import gnureadline as readline

So in SITL calling… such as: -v ArduCopter -f quad -l 33.74111111,-118.37460000000002,44.0,270.0 --use-dir=BigW --console -m “–cmd=“module load misseditor;module load graph;graph RANGEFINDER.distance;param set DISARM_DELAY 0;calpress;batreset””*
gives above error, but executing compiled arducopter alone as in above:
build/sitl/bin/arducopter -S --model + --speedup 1 --slave 0 --defaults /Users/xxxxxx/Documents_outofthecloud/Desarrollo/GitHub/ardupilot/Tools/autotest/default_params/copter.parm -I0 --home 33.74111111,-118.37460000000002,44.0,270.0
works, and simulation can be done but without features depending on

I have done many reinstallations, but nothing has worked. What can I do?
Or a general reason for why those imports fail when called from, but not when called from the interpreter called by