mailinabox
mailinabox copied to clipboard
Python rtyaml Module Missing
It seems that a recent upgrade, possibly of Python 3.10 or Duplicity, removed Josh’s rtyaml Python module https://pypi.org/project/rtyaml/. This prevents proper execution of backup.py, dns_update.py, management.sh, utils.py, and web_update.py. To confirm that the rtyaml module is missing, run pip list which will list all installed Python modules. It seems likely that the missing rtyaml module is the underlying cause of problem #2420.
It's installed explicitly into a virtualenv at https://github.com/mail-in-a-box/mailinabox/blob/162e509b8bf0683a70cf92fb8b7623c0dba5d051/setup/management.sh#L46 so running mailinabox should fix it. But in that issue, the backup command is invoked the wrong way, which probably explains the problem.
In this case you should run /usr/local/lib/mailinabox/env/bin/pip list That will use the mailinabox virtual environment
I had previously run curl -s https://mailinabox.email/setup.sh | sudo bash and now ran mailinabox as Josh suggested. Neither fixed the problem of the rtyaml module not being found. Running cd /root/mailinabox/management then python3 backup.py still returns ModuleNotFoundError: No module named 'rtyaml'. Nevertheless, running /usr/local/lib/mailinabox/env/bin/pip list confirms that the rtyaml module is installed in the virtualenv. For some reason, the rtyaml module in the virtualenv is not being found.
Don't put python3 in the command to start backup.py. Just give the path to the python script alone. It has a shebang line at the top to activate its virtualenv where its packages are installed.
I originally tried directly running backup.py in the management directory without the python3 command which returns backup.py: command not found even though running ls confirms that the backup.py file is in the management directory. The only command line I tried that works properly is ~/mailinabox/management# /usr/local/lib/mailinabox/env/bin/python3 backup.py which seems to indicate that the virtualenv is not being used unless the full path to python3 in the virtualenv is specified.
Did you run backup.py or ./backup.py?
The ./ makes a big difference! If you don't give your shell a path to find a command, it will first look at al the directories in the $PATH variable, and if it doesn't find a command there, it will give up with command not found.
I did run backup.py which failed. Running ./backup.py which specifies running from the current directory rather than the command search path does enable the shebang line in backup.py to direct running python3 from the virtualenv. Thanks for the suggestion. I should have realized that the MiaB management directory is not in the default system command search path.
Could be a nice improvement, to add the MiaB management directory to the command search path. I'm going to make that customization.
I had the same thought about appending the MiaB management directory to the command search path. I created a file named “Mail-in-a-Box_management.sh” owned by 0:0 with mode 644 and saved it to the /etc/profile.d directory. This file contains:
# If a Mail-in-a-Box management directory exists # then append it to the commamnd search path. if [ -d "/root/mailinabox/management" ] ; then PATH="$PATH:/root/mailinabox/management" fi
This customization should be harmless because the default search path retains priority and no change is made to the search path unless the MiaB management directory exists. For an informative discussion of the ways to change the command search path see: https://askubuntu.com/questions/866161/setting-path-variable-in-etc-environment-vs-profile
I had the same thought about appending the MiaB management directory to the command search path. I created a file named “Mail-in-a-Box_management.sh” owned by 0:0 with mode 644 and saved it to the /etc/profile.d directory. This file contains:
If a Mail-in-a-Box management directory exists
then append it to the commamnd search path.
if [ -d "/root/mailinabox/management" ] ; then PATH="$PATH:/root/mailinabox/management" fi
This customization should be harmless because the default search path retains priority and no change is made to the search path unless the MiaB management directory exists. For an informative discussion of the ways to change the command search path see: https://askubuntu.com/questions/866161/setting-path-variable-in-etc-environment-vs-profile
I applied it as such on my box using Ansible.