Cannot renew certificate "ImportError: cannot import name _remove_dead_weakref"

Hello, everybody,

I can’t renew my server certificate anymore. For more than 2 years everything ran without problems. Probably the problem started with the update of Ubuntu to version 17.10

I’ve been through several forums. But so far I haven’t found anything to help me with my problem.

Because of the effort I shy away from reinstalling the server.

Many greetings and thanks for the help in advance

My domain is:
www.gneisenau.org

I ran this command:
./letsencrypt-auto renew

It produced this output:
Error: couldn’t get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File “/opt/eff.org/certbot/venv/bin/letsencrypt”, line 7, in
from certbot.main import main
File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py”, line 4, in
import logging.handlers
File “/usr/lib/python2.7/logging/init.py”, line 26, in
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File “/usr/lib/python2.7/weakref.py”, line 14, in
from _weakref import (
ImportError: cannot import name _remove_dead_weakref

My web server is (include version):
Server version: Apache/2.4.27 (Ubuntu)
Server built: 2017-09-18T15:05:48

The operating system my web server runs on is (include version):
Ubuntu 17.10 (GNU/Linux 4.4.0-24-generic x86_64)

I can login to a root shell on my machine (yes or no, or I don’t know):
yes

I’m using a control panel to manage my site (no, or provide the name and version of the control panel):
no

1 Like

@jsha Can you take a look at this?

Thank you

I would rather suggest @bmw because this seems to be a client packaging issue rather than a server infrastructure issue.

The error is coming from the Python standard library on your system. I think there is either a problem with the Python installation or the virtual environment used by Certbot.

First, I’d try running sudo rm -rf /opt/eff.org and running letsencrypt-auto again.

If you still get the issue, do you get the same ImportError when you run:

python2 -c 'import weakref'

If so, you should run sudo rm -rf /opt/eff.org, try reinstalling python from apt-get, and running letsencrypt-auto again.

If not, do you get the error when you run:

cd $(mktemp -d)
virtualenv -p python2 venv
./venv/bin/python -c 'import weakref'

If so, you should also run sudo rm -rf /opt/eff.org, but try reinstalling the virtualenv package and running letsencrypt-auto again.

5 Likes

Ah perfect thank you. your recommendation worked

Working perfectly, thank you very much!

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