Error cannot import name _remove_dead_weakref

I am running Ubuntu 18.04 and I am getting this error:

Error: couldn't get currently installed version for
 /opt/[eff.org/certbot/venv/bin/letsencrypt](http://eff.org/certbot/venv/bin/letsencrypt):
Traceback (most recent call last):
  File "/opt/[eff.org/certbot/venv/bin/letsencrypt](http://eff.org/certbot/venv/bin/letsencrypt)", line 7, in <module>
    from certbot.main import main
  File
 "/opt/[eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py](http://eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py)", line 2, in <module>
    from certbot._internal import main as internal_main
  File
 "/opt/[eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/_internal/main.py](http://eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/_internal/main.py)", line 6, in <module>
    import logging.handlers
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref,
 collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref

Not sure why this started happening. Any help would be much appreciated.

Many thanks,
Andreas

Hi Andreas,

If you recently upgraded to Ubuntu 18.04 from an older version, you may need to delete the certbot-auto virtual environment and allow it to be automatically recreated:

sudo rm -rf /opt/eff.org/certbot
1 Like

If you could, try then installing certbot via snapd:


ok this has suppressed the error, thank you :slight_smile:

1 Like