AttributeError: 'NoneType' object has no attribute 'strip'

A few weeks ago I’ve successfully installed Let’s Encrypt certificate on my main domain + a few subdomains. Today I’ve tried to do the same with another subdomain and received an error.

I’ve tried to run a command: sudo letsencrypt --apache -d sub.mydomain.com

It produced this output:
An unexpected error occurred:
AttributeError: ‘NoneType’ object has no attribute 'strip’
Please see the logfiles in /var/log/letsencrypt for more details.

My operating system is Ubuntu 64-bit 16.04

My web server is Apache 2.4.18

Just in case: I am running this command as a root.
Thank you in advance.

Can you post the details from /var/log/letsencrypt ?

please enclose it in three back ticks ` on their own line before your paste, and again 3 back ticks on their own line after the paste - that will keep the formatting etc.

2016-12-08 13:11:34,730:DEBUG:letsencrypt.cli:Root logging level set at 30
2016-12-08 13:11:34,732:INFO:letsencrypt.cli:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2016-12-08 13:11:34,735:DEBUG:letsencrypt.cli:letsencrypt version: 0.4.1
2016-12-08 13:11:34,735:DEBUG:letsencrypt.cli:Arguments: ['--apache', '-d', 'sub.mydomain.com']
2016-12-08 13:11:34,736:DEBUG:letsencrypt.cli:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#webroot,PluginEntryPoint#null,PluginEntryPoint#manual,PluginEntryPoint#standalone)
2016-12-08 13:11:34,742:DEBUG:letsencrypt.cli:Requested authenticator apache and installer apache
2016-12-08 13:11:35,497:DEBUG:letsencrypt.cli:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/bin/letsencrypt", line 9, in <module>
    load_entry_point('letsencrypt==0.4.1', 'console_scripts', 'letsencrypt')()
  File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 1986, in main
    return config.func(config, plugins)
  File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 653, in run
    installer, authenticator = choose_configurator_plugins(config, plugins, "run")
  File "/usr/lib/python2.7/dist-packages/letsencrypt/cli.py", line 623, in choose_configurator_plugins
    authenticator = installer = display_ops.pick_configurator(config, req_inst, plugins)
  File "/usr/lib/python2.7/dist-packages/letsencrypt/display/ops.py", line 135, in pick_configurator
    (interfaces.IAuthenticator, interfaces.IInstaller))
  File "/usr/lib/python2.7/dist-packages/letsencrypt/display/ops.py", line 92, in pick_plugin
    verified.prepare()
  File "/usr/lib/python2.7/dist-packages/letsencrypt/plugins/disco.py", line 213, in prepare
    return [plugin_ep.prepare() for plugin_ep in self._plugins.itervalues()]
  File "/usr/lib/python2.7/dist-packages/letsencrypt/plugins/disco.py", line 103, in prepare
    self._initialized.prepare()
  File "/usr/lib/python2.7/dist-packages/letsencrypt_apache/configurator.py", line 177, in prepare
    self.vhosts = self.get_virtual_hosts()
  File "/usr/lib/python2.7/dist-packages/letsencrypt_apache/configurator.py", line 549, in get_virtual_hosts
    new_vhost = self._create_vhost(path)
  File "/usr/lib/python2.7/dist-packages/letsencrypt_apache/configurator.py", line 509, in _create_vhost
    if self.parser.find_dir("SSLEngine", "on", start=path, exclude=False):
  File "/usr/lib/python2.7/dist-packages/letsencrypt_apache/parser.py", line 318, in find_dir
    self._get_include_path(self.get_arg(match + "/arg")),
  File "/usr/lib/python2.7/dist-packages/letsencrypt_apache/parser.py", line 339, in get_arg
    value = value.strip("'\"")
AttributeError: 'NoneType' object has no attribute 'strip'


Thanks,

As far as I can tell from this, it’s an older bug which has since been fixed. Personally I’d update to the latest version of letsencrypt/ certbot code.

unless someone else may have an idea of a workaround

2 Likes

What is your output of

sudo ./letsencrypt-auto --version

Latest version is 0.9.3 but your log shows 0.4.1. Did you install LE from a repo?

You should clone from the GIT repo to a directory /opt/certbot and then run your letsencrypt-auto / certbot-auto from that directory.

sudo git clone https://github.com/certbot/certbot /opt/certbot

@serverco Yip that’s the first thing I picked up v 0.4.1

It says that version is 0.4.1. I’ve installed it through sudo apt-get install python-letsencrypt-apache.
Thank you, I’ll try it out.

Installing from Distro Repositories is generally not a good idea as they do not seem to keep them updated at all. Scary to think Ubuntu thinks 0.4.1 is ok to push out via apt-get

The git clone command above will ensure you start off with the latest version and every time you run it thereafter it will also update itself and it’s python dependencies if needed.

I got the same error with the latest version of letsencrypt:

root@newvm:/opt/certbot# ./letsencrypt-auto --apache -d sub.mydomain.com
Bootstrapping dependencies for Debian-based OSes...
Hit:1 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease
Hit:2 http://mirrors.digitalocean.com/ubuntu xenial InRelease
Get:3 http://mirrors.digitalocean.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://mirrors.digitalocean.com/ubuntu xenial-backports InRelease [102 kB]
Get:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:6 http://mirrors.digitalocean.com/ubuntu xenial-updates/main Sources [210 kB]
Get:7 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe Sources [112 kB]
Get:8 http://mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 Packages [440 kB]
Get:9 http://mirrors.digitalocean.com/ubuntu xenial-updates/main i386 Packages [433 kB]
Get:10 http://mirrors.digitalocean.com/ubuntu xenial-updates/main Translation-en [171 kB]
Get:11 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 Packages [368 kB]
Get:12 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe i386 Packages [364 kB]
Get:13 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe Translation-en [134 kB]
Get:14 http://security.ubuntu.com/ubuntu xenial-security/main Sources [52.5 kB]
Get:15 http://security.ubuntu.com/ubuntu xenial-security/universe Sources [14.9 kB]
Get:16 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [189 kB]
Get:17 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages [183 kB]
Get:18 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [64.5 kB]
Get:19 http://security.ubuntu.com/ubuntu xenial-security/universe i386 Packages [62.3 kB]
Get:20 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [35.1 kB]
Fetched 3,139 kB in 1s (1,996 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
augeas-lenses is already the newest version (1.4.0-0ubuntu1).
augeas-lenses set to manually installed.
ca-certificates is already the newest version (20160104ubuntu1).
gcc is already the newest version (4:5.3.1-1ubuntu1).
gcc set to manually installed.
libaugeas0 is already the newest version (1.4.0-0ubuntu1).
libaugeas0 set to manually installed.
python is already the newest version (2.7.11-1).
python set to manually installed.
dialog is already the newest version (1.3-20160209-1).
dialog set to manually installed.
libssl-dev is already the newest version (1.0.2j-1+deb.sury.org~xenial+1).
libssl-dev set to manually installed.
The following NEW packages will be installed:
  libexpat1-dev libffi-dev libpython-dev libpython2.7 libpython2.7-dev
  python-dev python-pip-whl python-virtualenv python2.7-dev python3-virtualenv
  virtualenv
0 upgraded, 11 newly installed, 0 to remove and 14 not upgraded.
Need to get 30.6 MB of archives.
After this operation, 47.6 MB of additional disk space will be used.
Get:1 http://mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 libexpat1-dev amd64 2.1.0-7ubuntu0.16.04.2 [115 kB]
Get:2 http://mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 libpython2.7 amd64 2.7.12-1ubuntu0~16.04.1 [1,070 kB]
Get:3 http://mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 libpython2.7-dev amd64 2.7.12-1ubuntu0~16.04.1 [27.8 MB]
Get:4 http://mirrors.digitalocean.com/ubuntu xenial/main amd64 libpython-dev amd64 2.7.11-1 [7,728 B]
Get:5 http://mirrors.digitalocean.com/ubuntu xenial-updates/main amd64 python2.7-dev amd64 2.7.12-1ubuntu0~16.04.1 [276 kB]
Get:6 http://mirrors.digitalocean.com/ubuntu xenial/main amd64 python-dev amd64 2.7.11-1 [1,160 B]
Get:7 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 python-pip-whl all 8.1.1-2ubuntu0.4 [1,110 kB]
Get:8 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 python-virtualenv all 15.0.1+ds-3ubuntu1 [46.6 kB]
Get:9 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 python3-virtualenv all 15.0.1+ds-3ubuntu1 [43.2 kB]
Get:10 http://mirrors.digitalocean.com/ubuntu xenial-updates/universe amd64 virtualenv all 15.0.1+ds-3ubuntu1 [4,342 B]
Get:11 http://mirrors.digitalocean.com/ubuntu xenial/main amd64 libffi-dev amd64 3.2.1-4 [161 kB]
Fetched 30.6 MB in 0s (37.6 MB/s)
Selecting previously unselected package libexpat1-dev:amd64.
(Reading database ... 69814 files and directories currently installed.)
Preparing to unpack .../libexpat1-dev_2.1.0-7ubuntu0.16.04.2_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.2) ...
Selecting previously unselected package libpython2.7:amd64.
Preparing to unpack .../libpython2.7_2.7.12-1ubuntu0~16.04.1_amd64.deb ...
Unpacking libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.1) ...
Selecting previously unselected package libpython2.7-dev:amd64.
Preparing to unpack .../libpython2.7-dev_2.7.12-1ubuntu0~16.04.1_amd64.deb ...
Unpacking libpython2.7-dev:amd64 (2.7.12-1ubuntu0~16.04.1) ...
Selecting previously unselected package libpython-dev:amd64.
Preparing to unpack .../libpython-dev_2.7.11-1_amd64.deb ...
Unpacking libpython-dev:amd64 (2.7.11-1) ...
Selecting previously unselected package python2.7-dev.
Preparing to unpack .../python2.7-dev_2.7.12-1ubuntu0~16.04.1_amd64.deb ...
Unpacking python2.7-dev (2.7.12-1ubuntu0~16.04.1) ...
Selecting previously unselected package python-dev.
Preparing to unpack .../python-dev_2.7.11-1_amd64.deb ...
Unpacking python-dev (2.7.11-1) ...
Selecting previously unselected package python-pip-whl.
Preparing to unpack .../python-pip-whl_8.1.1-2ubuntu0.4_all.deb ...
Unpacking python-pip-whl (8.1.1-2ubuntu0.4) ...
Selecting previously unselected package python-virtualenv.
Preparing to unpack .../python-virtualenv_15.0.1+ds-3ubuntu1_all.deb ...
Unpacking python-virtualenv (15.0.1+ds-3ubuntu1) ...
Selecting previously unselected package python3-virtualenv.
Preparing to unpack .../python3-virtualenv_15.0.1+ds-3ubuntu1_all.deb ...
Unpacking python3-virtualenv (15.0.1+ds-3ubuntu1) ...
Selecting previously unselected package virtualenv.
Preparing to unpack .../virtualenv_15.0.1+ds-3ubuntu1_all.deb ...
Unpacking virtualenv (15.0.1+ds-3ubuntu1) ...
Selecting previously unselected package libffi-dev:amd64.
Preparing to unpack .../libffi-dev_3.2.1-4_amd64.deb ...
Unpacking libffi-dev:amd64 (3.2.1-4) ...
Processing triggers for libc-bin (2.23-0ubuntu4) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for install-info (6.1.0.dfsg.1-5) ...
Setting up libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.2) ...
Setting up libpython2.7:amd64 (2.7.12-1ubuntu0~16.04.1) ...
Setting up libpython2.7-dev:amd64 (2.7.12-1ubuntu0~16.04.1) ...
Setting up libpython-dev:amd64 (2.7.11-1) ...
Setting up python2.7-dev (2.7.12-1ubuntu0~16.04.1) ...
Setting up python-dev (2.7.11-1) ...
Setting up python-pip-whl (8.1.1-2ubuntu0.4) ...
Setting up python-virtualenv (15.0.1+ds-3ubuntu1) ...
Setting up python3-virtualenv (15.0.1+ds-3ubuntu1) ...
Setting up virtualenv (15.0.1+ds-3ubuntu1) ...
Setting up libffi-dev:amd64 (3.2.1-4) ...
Processing triggers for libc-bin (2.23-0ubuntu4) ...
Creating virtual environment...
Installing Python packages...
Installation succeeded.
   lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
   x Saving debug log to /var/log/letsencrypt/letsencrypt.log             x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   x                                                                      x
   mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

An unexpected error occurred:
AttributeError: 'NoneType' object has no attribute 'strip'
Please see the logfiles in /var/log/letsencrypt for more details.

Just try and run this for me and post the output here (change your email address and domain name of course)

sudo ./certbot-auto certonly --agree-tos --rsa-key-size 4096 -m youremail@wherever.com -d sub.yourdomain.com --renew-by-default --dry-run

root@newvm:/opt/certbot# sudo ./certbot-auto certonly --agree-tos --rsa-key-size 4096 -m my@email.com -d sub.domain.com --renew-by-default --dry-run




















                                                                                 lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqk
                                                                                 x Saving debug log to /var/log/letsencrypt/letsencrypt.log             x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 x                                                                      x
                                                                                 mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj




















An unexpected error occurred:
AttributeError: 'NoneType' object has no attribute 'strip'
Please see the logfiles in /var/log/letsencrypt for more details.

Please post the contents of /var/log/letsencrypt/letsencrypt.log

When you ran that command did it give you the pop up blue screen asking you to pick an authentication method?

No, it didn’t.

2016-12-08 13:43:35,315:DEBUG:certbot.main:Root logging level set at 20
2016-12-08 13:43:35,317:INFO:certbot.main:Saving debug log to /var/log/letsencrypt/letsencrypt.log
2016-12-08 13:43:35,331:DEBUG:certbot.main:certbot version: 0.9.3
2016-12-08 13:43:35,331:DEBUG:certbot.main:Arguments: ['--agree-tos', '--rsa-key-size', '4096', '-m', 'my@email.com', '-d', 'sub.mydomain.com', '--renew-by-default', '--dry-run']
2016-12-08 13:43:35,333:DEBUG:certbot.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#nginx,PluginEntryPoint#standalone,PluginEntryPoint#manual,PluginEntryPoint#webroot,PluginEntryPoint#apache,PluginEntryPoint#null)
2016-12-08 13:43:35,339:DEBUG:certbot.plugins.selection:Requested authenticator None and installer None
2016-12-08 13:43:36,695:DEBUG:certbot.main:Exiting abnormally:
Traceback (most recent call last):
  File "/root/.local/share/letsencrypt/bin/letsencrypt", line 11, in <module>
    sys.exit(main())
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/main.py", line 776, in main
    return config.func(config, plugins)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/main.py", line 554, in obtain_cert
    installer, auth = plug_sel.choose_configurator_plugins(config, plugins, "certonly")
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/plugins/selection.py", line 190, in choose_configurator_plugins
    authenticator = pick_authenticator(config, req_auth, plugins)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/plugins/selection.py", line 40, in pick_authenticator
    config, default, plugins, question, (interfaces.IAuthenticator,))
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/plugins/selection.py", line 77, in pick_plugin
    verified.prepare()
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/plugins/disco.py", line 220, in prepare
    return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/plugins/disco.py", line 106, in prepare
    self._initialized.prepare()
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot_apache/configurator.py", line 193, in prepare
    self.vhosts = self.get_virtual_hosts()
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot_apache/configurator.py", line 578, in get_virtual_hosts
    new_vhost = self._create_vhost(path)
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot_apache/configurator.py", line 533, in _create_vhost
    if self.parser.find_dir("SSLEngine", "on", start=path, exclude=False):
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot_apache/parser.py", line 318, in find_dir
    self._get_include_path(self.get_arg(match + "/arg")),
  File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot_apache/parser.py", line 339, in get_arg
    value = value.strip("'\"")
AttributeError: 'NoneType' object has no attribute 'strip'

Looks like it’s perhaps mixing up with the first install you did from apt-get originally.

I would have to test this first but if you are familiar with cleaning up installs … try removing the 0.4.1 and purging it completely, delete the /opt/certbot folder and then start from scratch again with a fresh clone which will reinstall python along with it.

sudo apt-get remove --purge python-letsencrypt-apache

As I say I would first need to test this on a test box for you so if you can wait I can see what the outcome of all of this would be. Just loading up a VM to test this.

I’m getting the same error still. :frowning:

I guess that there might be a problem with some dependency. This started happening after I installed a few things (memcached, APC, APCu and something else). Some of these extensions use python as well.

Just hang fire and let me test with the way you originally installed letsencrypt and see if I get a similar outcome to you. I don’t think memcached or APC would have done that. you could try

sudo apt-get install --reinstall python2.7

To see if it will fix python and all its dependencies but I am testing this on a VM now so perhaps let me see if I get the same errors as you

It didn’t help unfortunately. I’ve also noticed that I have different versions of python installed. Could it be the problem?
Here is a full list of my packages:

accountsservice                                 install
acl                                             install
acpid                                           install
adduser                                         install
apache2                                         install
apache2-bin                                     install
apache2-data                                    install
apache2-utils                                   install
apparmor                                        install
apport                                          install
apport-symptoms                                 install
apt                                             install
apt-transport-https                             install
apt-utils                                       install
arping                                          install
at                                              install
augeas-lenses                                   install
autoconf                                        install
automake                                        install
autotools-dev                                   install
base-files                                      install
base-passwd                                     install
bash                                            install
bash-completion                                 install
bcache-tools                                    install
bind9-host                                      install
binutils                                        install
bsdmainutils                                    install
bsdutils                                        install
btrfs-tools                                     install
build-essential                                 install
busybox-initramfs                               install
busybox-static                                  install
byobu                                           install
bzip2                                           install
ca-certificates                                 install
cloud-guest-utils                               install
cloud-init                                      install
cloud-initramfs-copymods                        install
cloud-initramfs-dyn-netconf                     install
cloud-initramfs-growroot                        install
command-not-found                               install
command-not-found-data                          install
console-setup                                   install
console-setup-linux                             install
coreutils                                       install
cpio                                            install
cpp                                             install
cpp-5                                           install
cron                                            install
cryptsetup                                      install
cryptsetup-bin                                  install
curl                                            install
dash                                            install
dbus                                            install
debconf                                         install
debconf-i18n                                    install
debhelper                                       install
debianutils                                     install
dh-php                                          install
dh-python                                       install
dh-strip-nondeterminism                         install
dialog                                          install
dictionaries-common                             install
diffutils                                       install
discover                                        install
discover-data                                   install
distro-info-data                                install
dmeventd                                        install
dmidecode                                       install
dmsetup                                         install
dns-root-data                                   install
dnsmasq-base                                    install
dnsutils                                        install
dosfstools                                      install
dpkg                                            install
dpkg-dev                                        install
e2fslibs:amd64                                  install
e2fsprogs                                       install
eatmydata                                       install
ed                                              install
eject                                           install
emacsen-common                                  install
ethtool                                         install
fakeroot                                        install
file                                            install
findutils                                       install
fontconfig-config                               install
fonts-dejavu-core                               install
fonts-ubuntu-font-family-console                install
friendly-recovery                               install
ftp                                             install
fuse                                            install
g++                                             install
g++-5                                           install
gawk                                            install
gcc                                             install
gcc-5                                           install
gcc-5-base:amd64                                install
gcc-6-base:amd64                                install
gdisk                                           install
geoip-database                                  install
gettext                                         install
gettext-base                                    install
gir1.2-glib-2.0:amd64                           install
git                                             install
git-man                                         install
gnupg                                           install
gpgv                                            install
grep                                            install
groff-base                                      install
grub-common                                     install
grub-gfxpayload-lists                           install
grub-pc                                         install
grub-pc-bin                                     install
grub2-common                                    install
gzip                                            install
hdparm                                          install
hostname                                        install
ifenslave                                       install
ifupdown                                        install
info                                            install
init                                            install
init-system-helpers                             install
initramfs-tools                                 install
initramfs-tools-bin                             install
initramfs-tools-core                            install
initscripts                                     install
insserv                                         install
install-info                                    install
installation-report                             install
intltool-debian                                 install
iproute2                                        install
iptables                                        install
iputils-ping                                    install
iputils-tracepath                               install
irqbalance                                      install
isc-dhcp-client                                 install
isc-dhcp-common                                 install
iso-codes                                       install
kbd                                             install
keyboard-configuration                          install
klibc-utils                                     install
kmod                                            install
krb5-locales                                    install
language-pack-en                                install
language-pack-en-base                           install
language-pack-gnome-en                          install
language-pack-gnome-en-base                     install
language-selector-common                        install
laptop-detect                                   install
less                                            install
libaccountsservice0:amd64                       install
libacl1:amd64                                   install
libaio1:amd64                                   install
libalgorithm-diff-perl                          install
libalgorithm-diff-xs-perl                       install
libalgorithm-merge-perl                         install
libapache2-mod-php                              install
libapache2-mod-php5.6                           install
libapache2-mod-php7.0                           install
libapparmor-perl                                install
libapparmor1:amd64                              install
libapr1:amd64                                   install
libaprutil1:amd64                               install
libaprutil1-dbd-sqlite3:amd64                   install
libaprutil1-ldap:amd64                          install
libapt-inst2.0:amd64                            install
libapt-pkg5.0:amd64                             install
libarchive-zip-perl                             install
libasan2:amd64                                  install
libasn1-8-heimdal:amd64                         install
libasprintf-dev:amd64                           install
libasprintf0v5:amd64                            install
libatm1:amd64                                   install
libatomic1:amd64                                install
libattr1:amd64                                  install
libaudit-common                                 install
libaudit1:amd64                                 install
libaugeas0                                      install
libbind9-140:amd64                              install
libblkid1:amd64                                 install
libbsd0:amd64                                   install
libbz2-1.0:amd64                                install
libc-bin                                        install
libc-dev-bin                                    install
libc6:amd64                                     install
libc6-dev:amd64                                 install
libcap-ng0:amd64                                install
libcap2:amd64                                   install
libcap2-bin                                     install
libcc1-0:amd64                                  install
libcgi-fast-perl                                install
libcgi-pm-perl                                  install
libcilkrts5:amd64                               install
libcomerr2:amd64                                install
libcroco3:amd64                                 install
libcryptsetup4:amd64                            install
libcurl3:amd64                                  install
libcurl3-gnutls:amd64                           install
libdb5.3:amd64                                  install
libdbus-1-3:amd64                               install
libdbus-glib-1-2:amd64                          install
libdebconfclient0:amd64                         install
libdevmapper-event1.02.1:amd64                  install
libdevmapper1.02.1:amd64                        install
libdiscover2                                    install
libdns-export162                                install
libdns162:amd64                                 install
libdpkg-perl                                    install
libdrm2:amd64                                   install
libdumbnet1:amd64                               install
libeatmydata1:amd64                             install
libedit2:amd64                                  install
libelf1:amd64                                   install
libencode-locale-perl                           install
liberror-perl                                   install
libestr0                                        install
libevent-2.0-5:amd64                            install
libevent-core-2.0-5:amd64                       install
libexpat1:amd64                                 install
libexpat1-dev:amd64                             install
libexporter-tiny-perl                           install
libfakeroot:amd64                               install
libfcgi-perl                                    install
libfdisk1:amd64                                 install
libffi-dev:amd64                                install
libffi6:amd64                                   install
libfile-fcntllock-perl                          install
libfile-stripnondeterminism-perl                install
libfontconfig1:amd64                            install
libfreetype6:amd64                              install
libfribidi0:amd64                               install
libfuse2:amd64                                  install
libgcc-5-dev:amd64                              install
libgcc1:amd64                                   install
libgcrypt20:amd64                               install
libgd3:amd64                                    install
libgdbm3:amd64                                  install
libgeoip1:amd64                                 install
libgettextpo-dev:amd64                          install
libgettextpo0:amd64                             install
libgirepository-1.0-1:amd64                     install
libglib2.0-0:amd64                              install
libglib2.0-data                                 install
libgmp10:amd64                                  install
libgnutls-openssl27:amd64                       install
libgnutls30:amd64                               install
libgomp1:amd64                                  install
libgpg-error0:amd64                             install
libgpm2:amd64                                   install
libgssapi-krb5-2:amd64                          install
libgssapi3-heimdal:amd64                        install
libhcrypto4-heimdal:amd64                       install
libheimbase1-heimdal:amd64                      install
libheimntlm0-heimdal:amd64                      install
libhogweed4:amd64                               install
libhtml-parser-perl                             install
libhtml-tagset-perl                             install
libhtml-template-perl                           install
libhttp-date-perl                               install
libhttp-message-perl                            install
libhx509-5-heimdal:amd64                        install
libicu55:amd64                                  install
libidn11:amd64                                  install
libio-html-perl                                 install
libisc-export160                                install
libisc160:amd64                                 install
libisccc140:amd64                               install
libisccfg140:amd64                              install
libisl15:amd64                                  install
libitm1:amd64                                   install
libjbig0:amd64                                  install
libjpeg-turbo8:amd64                            install
libjpeg8:amd64                                  install
libjson-c2:amd64                                install
libk5crypto3:amd64                              install
libkeyutils1:amd64                              install
libklibc                                        install
libkmod2:amd64                                  install
libkrb5-26-heimdal:amd64                        install
libkrb5-3:amd64                                 install
libkrb5support0:amd64                           install
libldap-2.4-2:amd64                             install
liblist-moreutils-perl                          install
liblocale-gettext-perl                          install
liblsan0:amd64                                  install
libltdl-dev:amd64                               install
libltdl7:amd64                                  install
liblua5.1-0:amd64                               install
liblvm2app2.2:amd64                             install
liblvm2cmd2.02:amd64                            install
liblwp-mediatypes-perl                          install
liblwres141:amd64                               install
liblxc1                                         install
liblz4-1:amd64                                  install
liblzma5:amd64                                  install
liblzo2-2:amd64                                 install
libmagic1:amd64                                 install
libmail-sendmail-perl                           install
libmcrypt4                                      install
libmemcached11:amd64                            install
libmnl0:amd64                                   install
libmount1:amd64                                 install
libmpc3:amd64                                   install
libmpdec2:amd64                                 install
libmpfr4:amd64                                  install
libmpx0:amd64                                   install
libmspack0:amd64                                install
libncurses5:amd64                               install
libncursesw5:amd64                              install
libnet1:amd64                                   install
libnetfilter-conntrack3:amd64                   install
libnettle6:amd64                                install
libnewt0.52:amd64                               install
libnfnetlink0:amd64                             install
libnih1:amd64                                   install
libnss-myhostname:amd64                         install
libnuma1:amd64                                  install
libp11-kit0:amd64                               install
libpam-modules:amd64                            install
libpam-modules-bin                              install
libpam-runtime                                  install
libpam-systemd:amd64                            install
libpam0g:amd64                                  install
libparted2:amd64                                install
libpcap0.8:amd64                                install
libpci3:amd64                                   install
libpcre16-3:amd64                               install
libpcre3:amd64                                  install
libpcre3-dev:amd64                              install
libpcre32-3:amd64                               install
libpcrecpp0v5:amd64                             install
libperl5.22:amd64                               install
libpipeline1:amd64                              install
libplymouth4:amd64                              install
libpng12-0:amd64                                install
libpolkit-agent-1-0:amd64                       install
libpolkit-backend-1-0:amd64                     install
libpolkit-gobject-1-0:amd64                     install
libpopt0:amd64                                  install
libprocps4:amd64                                install
libpython-dev:amd64                             install
libpython-stdlib:amd64                          install
libpython2.7:amd64                              install
libpython2.7-dev:amd64                          install
libpython2.7-minimal:amd64                      install
libpython2.7-stdlib:amd64                       install
libpython3-stdlib:amd64                         install
libpython3.5:amd64                              install
libpython3.5-minimal:amd64                      install
libpython3.5-stdlib:amd64                       install
libquadmath0:amd64                              install
libreadline5:amd64                              install
libreadline6:amd64                              install
libroken18-heimdal:amd64                        install
librtmp1:amd64                                  install
libsasl2-2:amd64                                install
libsasl2-modules:amd64                          install
libsasl2-modules-db:amd64                       install
libseccomp2:amd64                               install
libselinux1:amd64                               install
libsemanage-common                              install
libsemanage1:amd64                              install
libsepol1:amd64                                 install
libsigsegv2:amd64                               install
libslang2:amd64                                 install
libsmartcols1:amd64                             install
libsqlite3-0:amd64                              install
libss2:amd64                                    install
libssl-dev:amd64                                install
libssl-doc                                      install
libssl1.0.0:amd64                               install
libssl1.0.2:amd64                               install
libstdc++-5-dev:amd64                           install
libstdc++6:amd64                                install
libsys-hostname-long-perl                       install
libsystemd0:amd64                               install
libtasn1-6:amd64                                install
libtext-charwidth-perl                          install
libtext-iconv-perl                              install
libtext-wrapi18n-perl                           install
libtiff5:amd64                                  install
libtimedate-perl                                install
libtinfo5:amd64                                 install
libtool                                         install
libtsan0:amd64                                  install
libubsan0:amd64                                 install
libudev1:amd64                                  install
libunistring0:amd64                             install
liburi-perl                                     install
libusb-0.1-4:amd64                              install
libusb-1.0-0:amd64                              install
libustr-1.0-1:amd64                             install
libutempter0:amd64                              install
libuuid1:amd64                                  install
libwebp5:amd64                                  install
libwind0-heimdal:amd64                          install
libwrap0:amd64                                  install
libx11-6:amd64                                  install
libx11-data                                     install
libxau6:amd64                                   install
libxcb1:amd64                                   install
libxdmcp6:amd64                                 install
libxext6:amd64                                  install
libxml2:amd64                                   install
libxmuu1:amd64                                  install
libxpm4:amd64                                   install
libxslt1.1:amd64                                install
libxtables11:amd64                              install
libyaml-0-2:amd64                               install
libzip4:amd64                                   install
linux-base                                      install
linux-headers-4.4.0-47                          install
linux-headers-4.4.0-47-generic                  install
linux-headers-generic                           install
linux-headers-virtual                           install
linux-headers-virtual-lts-xenial                install
linux-image-4.4.0-47-generic                    install
linux-image-virtual                             install
linux-libc-dev:amd64                            install
linux-virtual                                   install
linux-virtual-lts-xenial                        install
locales                                         install
login                                           install
logrotate                                       install
lsb-base                                        install
lsb-release                                     install
lshw                                            install
lsof                                            install
ltrace                                          install
lvm2                                            install
lxc-common                                      install
lxcfs                                           install
lxd                                             install
lxd-client                                      install
m4                                              install
make                                            install
makedev                                         install
man-db                                          install
manpages                                        install
manpages-dev                                    install
mawk                                            install
mdadm                                           install
mime-support                                    install
mlocate                                         install
mount                                           install
mtr-tiny                                        install
multiarch-support                               install
mysql-client-5.7                                install
mysql-client-core-5.7                           install
mysql-common                                    install
mysql-server                                    install
mysql-server-5.7                                install
mysql-server-core-5.7                           install
nano                                            install
ncurses-base                                    install
ncurses-bin                                     install
ncurses-term                                    install
net-tools                                       install
netbase                                         install
netcat-openbsd                                  install
ntfs-3g                                         install
open-iscsi                                      install
openssh-client                                  install
openssh-server                                  install
openssh-sftp-server                             install
openssl                                         install
os-prober                                       install
overlayroot                                     install
parted                                          install
passwd                                          install
pastebinit                                      install
patch                                           install
pciutils                                        install
perl                                            install
perl-base                                       install
perl-modules-5.22                               install
php                                             install
php-cli                                         install
php-common                                      install
php-curl                                        install
php-dev                                         install
php-igbinary                                    install
php-mbstring                                    install
php-mcrypt                                      install
php-memcached                                   install
php-msgpack                                     install
php-mysql                                       install
php-pear                                        install
php-xml                                         install
php-zip                                         install
php5.6                                          install
php5.6-cli                                      install
php5.6-common                                   install
php5.6-gd                                       install
php5.6-json                                     install
php5.6-mcrypt                                   install
php5.6-mysql                                    install
php5.6-opcache                                  install
php5.6-readline                                 install
php7.0                                          install
php7.0-cli                                      install
php7.0-common                                   install
php7.0-curl                                     install
php7.0-dev                                      install
php7.0-json                                     install
php7.0-mbstring                                 install
php7.0-mcrypt                                   install
php7.0-mysql                                    install
php7.0-opcache                                  install
php7.0-readline                                 install
php7.0-xml                                      install
php7.0-zip                                      install
pkg-php-tools                                   install
plymouth                                        install
plymouth-theme-ubuntu-text                      install
po-debconf                                      install
policykit-1                                     install
pollinate                                       install
popularity-contest                              install
powermgmt-base                                  install
procps                                          install
psmisc                                          install
python                                          install
python-apt                                      install
python-apt-common                               install
python-dev                                      install
python-minimal                                  install
python-pip-whl                                  install
python-pkg-resources                            install
python-pycurl                                   install
python-software-properties                      install
python-virtualenv                               install
python2.7                                       install
python2.7-dev                                   install
python2.7-minimal                               install
python3                                         install
python3-apport                                  install
python3-apt                                     install
python3-blinker                                 install
python3-cffi-backend                            install
python3-chardet                                 install
python3-commandnotfound                         install
python3-configobj                               install
python3-cryptography                            install
python3-dbus                                    install
python3-debian                                  install
python3-distupgrade                             install
python3-gdbm:amd64                              install
python3-gi                                      install
python3-idna                                    install
python3-jinja2                                  install
python3-json-pointer                            install
python3-jsonpatch                               install

Didn’t fit everything into 1 post:

python3-jwt                                     install
python3-markupsafe                              install
python3-minimal                                 install
python3-newt                                    install
python3-oauthlib                                install
python3-pkg-resources                           install
python3-prettytable                             install
python3-problem-report                          install
python3-pyasn1                                  install
python3-pycurl                                  install
python3-requests                                install
python3-serial                                  install
python3-six                                     install
python3-software-properties                     install
python3-systemd                                 install
python3-update-manager                          install
python3-urllib3                                 install
python3-virtualenv                              install
python3-yaml                                    install
python3.5                                       install
python3.5-minimal                               install
readline-common                                 install
rename                                          install
resolvconf                                      install
rsync                                           install
rsyslog                                         install
run-one                                         install
screen                                          install
sed                                             install
sensible-utils                                  install
sgml-base                                       install
shared-mime-info                                install
shtool                                          install
snap-confine                                    install
snapd                                           install
software-properties-common                      install
sosreport                                       install
squashfs-tools                                  install
ssh-import-id                                   install
ssl-cert                                        install
strace                                          install
sudo                                            install
systemd                                         install
systemd-sysv                                    install
sysv-rc                                         install
sysvinit-utils                                  install
tar                                             install
tasksel                                         install
tasksel-data                                    install
tcpd                                            install
tcpdump                                         install
telnet                                          install
time                                            install
tmux                                            install
tzdata                                          install
ubuntu-cloudimage-keyring                       install
ubuntu-core-launcher                            install
ubuntu-keyring                                  install
ubuntu-minimal                                  install
ubuntu-release-upgrader-core                    install
ubuntu-standard                                 install
ucf                                             install
udev                                            install
ufw                                             install
uidmap                                          install
unattended-upgrades                             install
unzip                                           install
update-manager-core                             install
update-notifier-common                          install
ureadahead                                      install
usbutils                                        install
util-linux                                      install
uuid-runtime                                    install
vim                                             install
vim-common                                      install
vim-runtime                                     install
vim-tiny                                        install
virtualenv                                      install
vlan                                            install
wamerican                                       install
wbritish                                        install
wget                                            install
whiptail                                        install
xauth                                           install
xdg-user-dirs                                   install
xfsprogs                                        install
xkb-data                                        install
xml-core                                        install
xml2                                            install
xz-utils                                        install
zerofree                                        install
zip                                             install
zlib1g:amd64                                    install
zlib1g-dev:amd64                                install

I just did a clean install of 16.04 server

Then sudo apt-get install python-letsencrypt-apache

Then ran sudo letsencrypt certonly -d sb.pyroman.io --dry-run

and it immediately gave me the popup screen

and I did a sudo letsencrypt --version and got

LetsEncrypt 0.4.1

So I do think your python is a little messed up

It worked perfectly fine at first, I managed to generate a few certificates successfully, but after a while when I tried to do it again, there was an error.