July 10, 2021

Certbot - No module named '_cffi_backend'

Activities, Android Developer, Ansible, Apache2, Atlassian, Ayo Belajar Linux, Bestpath Network, BLC Telkom Klaten, BSD, Caddy Server, Case Study, Cisco, Cisco Indonesia, Cloud Computing, Cockpit, Custom Weapons, Docker, E-Learning, Engenius, Error, FreeBSD, FreeBSD Indonesia, Komunitas Pengguna Linux Indonesia, KPLI Bulukumba, KPLI Klaten, Let's Encrypt, Linux, MacOS, Microsoft Azure, Microsoft SQL Server, MikroTik, MikroTik Indonesia, MySQL, Nginx, Open edX, OpenSID, Others, PHP, phpMyAdmin, PostgreSQL, Proxmox, Python, Redash, Sendy, SSH, Stories, Subnetting, TP-Link, Ubiquiti, Unix, Virtualization, Windows, X-Mosque, Faizar Septiawan, Icar, siBunglonGanteng, Orang Ganteng, siBunglonLabs

Today, one of the server manage by me has failed to auto renew the https certificate.

Btw, i’m using certificate from R3 by Let’s Encrypt. When i tried to manual renew using sudo certbot renew, i got this error message (see below for the error message).

[email protected]:~$ sudo certbot renew
Traceback (most recent call last):
  File "/usr/bin/certbot", line 11, in <module>
    load_entry_point('certbot==0.31.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 10, in <module>
    import josepy as jose
  File "/usr/lib/python3/dist-packages/josepy/__init__.py", line 44, in <module>
    from josepy.interfaces import JSONDeSerializable
  File "/usr/lib/python3/dist-packages/josepy/interfaces.py", line 8, in <module>
    from josepy import errors, util
  File "/usr/lib/python3/dist-packages/josepy/util.py", line 4, in <module>
    import OpenSSL
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 12, in <module>
    from cryptography import x509
  File "/usr/lib/python3/dist-packages/cryptography/x509/__init__.py", line 9, in <module>
    from cryptography.x509.base import (
  File "/usr/lib/python3/dist-packages/cryptography/x509/base.py", line 16, in <module>
    from cryptography.x509.extensions import Extension, ExtensionType
  File "/usr/lib/python3/dist-packages/cryptography/x509/extensions.py", line 18, in <module>
    from cryptography.hazmat.primitives import constant_time, serialization
  File "/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/constant_time.py", line 9, in <module>
    from cryptography.hazmat.bindings._constant_time import lib
ModuleNotFoundError: No module named '_cffi_backend'

On the Stack Overflow, someone suggested installing the cffi package using python pip and i tried to install the package, but i got the error message again. No problem for me, this is challenge when tried to solve the issue but got a new issue. wkwk.

See below for a new error message.

[email protected]:~$ pip3 install -U cffi
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 267, in run
    with self._build_session(options) as session:
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 66, in _build_session
    session = PipSession(
  File "/usr/lib/python3/dist-packages/pip/download.py", line 321, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/lib/python3/dist-packages/pip/download.py", line 93, in user_agent
    zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'
Traceback (most recent call last):
  File "/usr/bin/pip3", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 217, in main
    return command.main(cmd_args)
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 242, in main
    with self._build_session(
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 66, in _build_session
    session = PipSession(
  File "/usr/lib/python3/dist-packages/pip/download.py", line 321, in __init__
    self.headers["User-Agent"] = user_agent()
  File "/usr/lib/python3/dist-packages/pip/download.py", line 93, in user_agent
    zip(["name", "version", "id"], platform.linux_distribution()),
AttributeError: module 'platform' has no attribute 'linux_distribution'

I think python3 pip on the server is crash. So i delete the python3 pip and re-install it using command curl -L get-pip.io | python3. After that, i tried again to install cffi package and successfull install the package.

[email protected]:~$ pip3 install -U cffi
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: cffi in /usr/lib/python3/dist-packages (1.10.0)
Collecting cffi
  Downloading cffi-1.14.5-cp38-cp38-manylinux1_x86_64.whl (411 kB)
     |████████████████████████████████| 411 kB 33.2 MB/s
Requirement already satisfied: pycparser in /usr/lib/python3/dist-packages (from cffi) (2.14)
Installing collected packages: cffi
Successfully installed cffi-1.14.5