LetsEncrypt Set up Failing

The instruction at Using Let's Encrypt to setup HTTPS for setting up https are failing for
sudo -H bench setup lets-encrypt [site-name]

with the following output

    virtualenv: error: unrecognized arguments: --no-site-packages
    Traceback (most recent call last):
      File "<stdin>", line 27, in <module>
      File "<stdin>", line 19, in create_venv
      File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
        raise CalledProcessError(retcode, cmd)

I was able to identify that this is because the command
sudo -H bench setup lets-encrypt [site-name]

is trying to use Python2 which is obsolete with letscrypt

Supposedly a workaround given at certbot-auto crashes when virtualenv is installed for Python3 · Issue #7828 · certbot/certbot · GitHub
is to use
USE_PYTHON_3=1 ./certbot-auto

But I was not sure how to modify the bench file especially in a production server where it is supposed to be non editable.

FYI, I also got that installed in editable model inspite of doing easy_install on a clean Ubuntu 18.04


/opt$ sudo USE_PYTHON_3=1 ./certbot-auto

also failed with

    Creating virtual environment...
    Traceback (most recent call last):
      File "<stdin>", line 27, in <module>
      File "<stdin>", line 23, in create_venv
      File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'venv', '/opt/eff.org/certbot/venv']' returned non-zero exit status 1.

I got it working and I have only a guess how it worked

When I tried it on another day
/opt sudo USE_PYTHON_3=1 ./certbot-auto
seemed to work fine.

That is basically going to /opt folder where where certbot-auto was present and simply running it with an environment variable.

Looks like last time when I had tried, I used the command in the same shell in which I ran
sudo -H bench setup lets-encrypt [site-name]

That possibly created some environment variable which interfered with the Python 3 command. Logging again from a different ssh seems to have fixed it.

FYI, when the system failed with bench setup, I had avoided the overwrite of the ngix config file. Hence my system remained online although without https

After installing the certificate from the opt folder, all I had to do was restart ngix and it managed to get the config right. My site automatically went https

I also assume that the cron job added by the following command will continue to work. Will update.
sudo -H bench setup lets-encrypt [site-name]