Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python rtyaml Module Missing #2421

Open
MSSEsq opened this issue Aug 7, 2024 · 10 comments
Open

Python rtyaml Module Missing #2421

MSSEsq opened this issue Aug 7, 2024 · 10 comments

Comments

@MSSEsq
Copy link

MSSEsq commented Aug 7, 2024

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.

@JoshData
Copy link
Member

JoshData commented Aug 7, 2024

It's installed explicitly into a virtualenv at

rtyaml "email_validator>=1.0.0" "exclusiveprocess" \
so running mailinabox should fix it. But in that issue, the backup command is invoked the wrong way, which probably explains the problem.

@kiekerjan
Copy link
Contributor

In this case you should run /usr/local/lib/mailinabox/env/bin/pip list That will use the mailinabox virtual environment

@MSSEsq
Copy link
Author

MSSEsq commented Aug 7, 2024

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.

@JoshData
Copy link
Member

JoshData commented Aug 7, 2024

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.

@MSSEsq
Copy link
Author

MSSEsq commented Aug 7, 2024

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.

@amedee
Copy link

amedee commented Aug 7, 2024

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.

@MSSEsq
Copy link
Author

MSSEsq commented Aug 7, 2024

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.

@amedee
Copy link

amedee commented Aug 8, 2024

Could be a nice improvement, to add the MiaB management directory to the command search path. I'm going to make that customization.

@MSSEsq
Copy link
Author

MSSEsq commented Aug 8, 2024

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

@amedee
Copy link

amedee commented Aug 10, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants