ImportError: cannot import name _remove_dead_weakref

I ran this command:
**/usr/local/bin/certbot-auto renew**

It produced this output:

Error: couldn’t get currently installed version for /opt/

Traceback (most recent call last):

File “/opt/”, line 7, in

from certbot.main import main

File “/opt/”, line 2, in

from certbot._internal import main as internal_main

File “/opt/”, line 6, in

import logging.handlers

File “/usr/lib/python2.7/logging/”, line 26, in

import sys, os, time, cStringIO, traceback, warnings, weakref, collections

File “/usr/lib/python2.7/”, line 14, in

from _weakref import (

ImportError: cannot import name _remove_dead_weakref

The operating system my web server runs on is (include version):
Operating System: Debian GNU/Linux 10 (buster)
Kernel: Linux 5.4.10-x86_64-linode132
Architecture: x86-64

My hosting provider, if applicable, is:

I can login to a root shell on my machine (yes or no, or I don’t know):
The version of my client is (e.g. output of certbot --version or certbot-auto --version if you’re using Certbot):

**root@linode (~ ): certbot --version**

**certbot 0.31.0**

Has the OS or CPython or something recently been upgraded?

Major changes can break certbot-auto and require it to be reinstalled.

You can do something like “sudo mv -i /opt/ /tmp/” to move the old installation, then run /usr/local/bin/certbot-auto again to reinstall it.

Do you need to have both certbot-auto and Certbot 0.31.0 (from the Debian package?) installed? Note that there’s probably a systemd timer installed that will (try to) renew your certificates using 0.31.0.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.