Error provisioning after update to Trellis: The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required

I have a DO droplet that I’ve provisioned with an earlier version of Trellis. I’ve updated Trellis and now I’m trying to provision the server again, and I’m running into the following error:

TASK [mariadb : Set root user password] ****************************************
System info:
  Ansible 2.10.16; Linux
  Trellis version (per changelog): "Remove Python 2 support"
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [188.166.49.18] (item=188.166.49.18) => {"ansible_loop_var": "item", "changed": false, "item": "188.166.49.18"}
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [188.166.49.18] (item=127.0.0.1) => {"ansible_loop_var": "item", "changed": false, "item": "127.0.0.1"}
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [188.166.49.18] (item=::1) => {"ansible_loop_var": "item", "changed": false, "item": "::1"}
---------------------------------------------------
The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module
is required.
failed: [188.166.49.18] (item=localhost) => {"ansible_loop_var": "item", "changed": false, "item": "localhost"}

PLAY RECAP *********************************************************************
188.166.49.18              : ok=55   changed=1    unreachable=0    failed=1    skipped=29   rescued=0    ignored=0
localhost                  : ok=0    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

exit status 2

I’ve tried installing the PyMySQL missing package, by installing python-pip and running sudo pip install pymysql, but I get an error message:

Collecting pymysql
  Downloading https://files.pythonhosted.org/packages/2b/c4/3c3e7e598b1b490a2525068c22f397fda13f48623b7bd54fb209cd0ab774/PyMySQL-1.0.0.tar.gz (45kB)
    100% |████████████████████████████████| 51kB 8.7MB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-Mbzlza/pymysql/setup.py", line 6, in <module>
        with open("./README.rst", encoding="utf-8") as f:
    TypeError: 'encoding' is an invalid keyword argument for this function

It also mentions the following:

The directory '/home/admin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/admin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

I’ve tried running sudo with the -H vlag, but it didn’t make a difference. I know I shouldn’t change anything on the server and let Trellis do the work, but I’m stuck. Anybody know why it tells me it’s missing the PyMySQL module? And is there some way I can Trellis that it should install it?

Update:
When I try to deploy to this server, I also get a “Remove Python 2 support” related error:

TASK [deploy : Update WP database] *********************************************
changed: [188.166.49.18]

TASK [deploy : Reload php-fpm] *************************************************
System info:
  Ansible 2.10.16; Linux
  Trellis version (per changelog): "Remove Python 2 support"
---------------------------------------------------
non-zero return code
sudo: no tty present and no askpass program specified
fatal: [188.166.49.18]: FAILED! => {"changed": true, "cmd": "sudo service php8.0-fpm reload", "delta": "0:00:00.017763", "end": "2022-03-23 09:48:44.839515", "rc": 1, "start": "2022-03-23 09:48:44.821752", "stderr_lines": ["sudo: no tty present and no askpass program specified"], "stdout": "", "stdout_lines": []}

PLAY RECAP *********************************************************************
188.166.49.18              : ok=32   changed=14   unreachable=0    failed=1    skipped=35   rescued=0    ignored=0
localhost                  : ok=0    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0

exit status 2

There’s an open issue about this with a few solutions: [BUG] Host uses wrong python interpreter · Issue #1371 · roots/trellis · GitHub

When I try to deploy to this server, I also get a “Remove Python 2 support” related error:

System info:
  Ansible 2.10.16; Linux
  Trellis version (per changelog): "Remove Python 2 support"

This is just outputting system info for troubleshooting purposes. It does not mean the error has anything to do with that Trellis version (“Remove Python 2 support” in this case)