Certbot renew problem (No module named _cffi_backend)

I am experiencing a problem with certbot on my system. I tried renew my certificates via certbot today but it didn’t work, showing me error messages attached in screenshot.

It was worked fine in a few week ago.

I already tried reinstalling certbot and python-cffi-backend via apt but no luck…

Currently I am using Ubuntu 18.04.4 LTS on my personal server.

Having any ideas? Thanks.

Hi @HaswellAoba,

Welcome to the community forum!

Can you try following the instructions at https://certbot.eff.org/lets-encrypt/ubuntubionic-other please? Let me know how that goes.

Hi @Phil_LE. Thanks for your reply.

But the problem was not fixed; It only shows me same error ( ModuleNotFoundError: No module named ‘_cffi_backend’ ) regarding any certbot commands…

Just out curiosity, what’s the output of which certbot and which certbot-auto? I’m curious if you’re accidently calling the broken certbot because of your $PATH environment variable.

My server returns me this for which certbot:

/usr/bin/certbot

and I got no output for which certbot-auto… Only blank.

Can you post the first few lines of /usr/bin/certbot, e.g. with “head /usr/bin/certbot”?

Here is the result.

#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'certbot==0.31.0','console_scripts','certbot'
__requires__ = 'certbot==0.31.0'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])

(and more)

What happens if you do:

/usr/bin/python3 -c "import _cffi_backend"
/usr/bin/python3 -c "import cryptography.hazmat.bindings._constant_time"
/usr/bin/python3 -c "from cryptography.hazmat.bindings._constant_time import lib"
sudo /usr/bin/python3 -c "import _cffi_backend"
sudo /usr/bin/python3 -c "import cryptography.hazmat.bindings._constant_time"
sudo /usr/bin/python3 -c "from cryptography.hazmat.bindings._constant_time import lib"
dpkg -l python3-cffi-backend python3-cryptography

Edit: Edited to add explicit /usr/bin/.

Edit: Additional questions:

What architecture are you on? (E.g. amd64.)

How did you install Certbot?

Every python command returns me ModuleNotFoundError: No module named _cffi_backend.

and this is my result for dpkg -l ~~

I am currently using x86_64 (AMD64) for my system.

I referred this guide for installing certbot: https://certbot.eff.org/lets-encrypt/ubuntubionic-other… Added PPA and just installed it.

I don’t get it. The package is installed but the module does not exist. :neutral_face:

Does the file exist? It should be here:

ls -l /usr/lib/python3/dist-packages/_cffi_backend.cpython-36m-x86_64-linux-gnu.so

I think it exists. Returns me
-rw-r--r-- 1 root root 169536 2월 28 2018 /usr/lib/python3/dist-packages/_cffi_backend.cpython-36m-x86_64-linux-gnu.so

I’m running low on ideas.

_cffi_backend.c is 8000 lines long and I don’t know anything about the CPython C API anyway. :neutral_face:

I’m speculating, but maybe this can happen if one of the other C libraries that the module requires does not load.

After googling it, I tried these commands:

python3 -m pip install cffi
python3 -m pip install certbot-nginx

and I now met this error( I did sudo certbot renew --force-renewal )

pkg_resources.VersionConflict: (certbot 0.31.0 (/usr/lib/python3/dist-packages),Requirement.parse('certbot>=1.1.0'))
Please see the logfile '/tmp/tmpbvzta98e' for more details. 

I think certbot or python on my system is somewhere broken. I have no idea where to fix.

Yeah, it seemed like something was broken before, which is probably supposed to be impossible. Like a library was missing or something (even though the package manager ought to handle it correctly). Or perhaps an incompatible version.

Now there’s another problem: Mixing packages installed with apt and pip can lead to issues.

(Also, pip can delete files that were installed by apt.)

Do you have the output from pip or a log of what it did?

This is what I received from the terminal:

$python3 -m pip install cffi
Collecting cffi
Using cached https://files.pythonhosted.org/packages/ff/1d/0b743dadcdf4980b717163fd2d24cd18c1c0c7a78a076268afd7e0e2c25e/cffi-1.14.0-cp37-cp37m-manylinux1_x86_64.whl
Collecting pycparser (from cffi)
Installing collected packages: pycparser, cffi
Successfully installed cffi-1.14.0 pycparser-2.19

Then I tried to run python3 -m pip install certbot-nginx since I am currently using nginx for my web server.

At first it returned me this:

(...)
Installing collected packages: mock, certifi, chardet, idna, urllib3, six, pycparser, cffi, cryptography, PyOpenSSL, requests, pytz, requests-toolbelt, setuptools, josepy, pyrfc3339, acme, pyparsing, distro, ConfigArgParse, parsedatetime, zope.interface, configobj, zope.proxy, zope.deferredimport, zope.event, zope.hookable, zope.deprecation, zope.component, certbot, certbot-nginx
Successfully installed ConfigArgParse-1.0 PyOpenSSL-19.1.0 acme-1.3.0 certbot-1.3.0 certbot-nginx-1.3.0 certifi-2019.11.28 cffi-1.14.0 chardet-3.0.4 configobj-5.0.6 cryptography-2.8 distro-1.4.0 idna-2.9 josepy-1.3.0 mock-4.0.1 parsedatetime-2.5 pycparser-2.19 pyparsing-2.4.6 pyrfc3339-1.1 pytz-2019.3 requests-2.23.0 requests-toolbelt-0.9.1 setuptools-45.2.0 six-1.14.0 urllib3-1.25.8 zope.component-4.6 zope.deferredimport-4.3.1 zope.deprecation-4.4.0 zope.event-4.4 zope.hookable-5.0.0 zope.interface-4.7.1 zope.proxy-4.3.3
Segmentation Error (core dumped)

So I googled again, executed sudo rm -rf ~/.local and tried python3 -m pip install certbot-nginx again and shows me this:

Collecting certbot-nginx
(...)
Installing collected packages: mock, pycparser, cffi, six, cryptography, PyOpenSSL, setuptools, josepy, chardet, certifi, idna, urllib3, requests, requests-toolbelt, pytz, pyrfc3339, acme, pyparsing, zope.interface, configobj, ConfigArgParse, zope.deprecation, zope.event, zope.proxy, zope.deferredimport, zope.hookable, zope.component, distro, parsedatetime, certbot, certbot-nginx
Successfully installed ConfigArgParse-1.0 PyOpenSSL-19.1.0 acme-1.3.0 certbot-1.3.0 certbot-nginx-1.3.0 certifi-2019.11.28 cffi-1.14.0 chardet-3.0.4 configobj-5.0.6 cryptography-2.8 distro-1.4.0 idna-2.9 josepy-1.3.0 mock-4.0.1 parsedatetime-2.5 pycparser-2.19 pyparsing-2.4.6 pyrfc3339-1.1 pytz-2019.3 requests-2.23.0 requests-toolbelt-0.9.1 setuptools-45.2.0 six-1.14.0 urllib3-1.25.8 zope.component-4.6 zope.deferredimport-4.3.1 zope.deprecation-4.4.0 zope.event-4.4 zope.hookable-5.0.0 zope.interface-4.7.1 zope.proxy-4.3.3

This is the output from pip that I did.

Um then should I delete modules installed with pip?