ModuleNotFoundError: No module named 'OpenSSL'

:uk:/:us: Message template (english)

My YunoHost server

Hardware: VPS bought online
YunoHost version: 11.2.11.3 (stable)
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no /

Description of my issue

Hello,
When I click on an option in the Domains list in the web interface, I get the following error. Thanks in advance to those who will help me with my problem and solution.

YunoHost encountered an internal error
Really sorry about that.
You should look for help on the forum or the chat to fix the situation, or report the bug on the bugtracker.
The following information might be useful for the person helping you:

Error: "500"

Action: "GET" /yunohost/api/domains/heartsapiens.art?locale=en

Error message:
Unexpected server error

Traceback

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/moulinette/interfaces/api.py", line 453, in process
    ret = self.actionsmap.process(arguments, timeout=30, route=_route)
  File "/usr/lib/python3/dist-packages/moulinette/actionsmap.py", line 580, in process
    return func(**arguments)
  File "/usr/lib/python3/dist-packages/yunohost/domain.py", line 162, in domain_info
    certificate = domain_cert_status([domain], full=True)["certificates"][domain]
  File "/usr/lib/python3/dist-packages/yunohost/domain.py", line 807, in domain_cert_status
    return certificate_status(domain_list, full)
  File "/usr/lib/python3/dist-packages/yunohost/certificate.py", line 86, in certificate_status
    status = _get_status(domain)
  File "/usr/lib/python3/dist-packages/yunohost/certificate.py", line 638, in _get_status
    from OpenSSL import crypto  # lazy loading this module for performance reasons
ModuleNotFoundError: No module named 'OpenSSL'

Can you share the output of

sudo dpkg --list | grep python3-openssl

sudo dpkg --list | grep python3-openssl

ii python3-openssl 20.0.1-1 all Python 3 wrapper around the OpenSSL library

All programs and applications are up to date. All services are reported as working properly.
However, in addition, the following problem started to occur.

The original message was received at Sat, 4 May 2024 07:51:36 +0300
from host-91-93-141-117.reverse.superonline.net [x.x.x.x] (may be forged)

   ----- The following addresses had permanent fatal errors -----
<catav@domain.ltd>
    (reason: 403 4.7.0 TLS handshake failed.)

   ----- Transcript of session follows -----
<catav@domain.ltd>... Deferred: 403 4.7.0 TLS handshake failed.
Message could not be delivered for 6 hours
Message will be deleted from queue


Reporting-MTA: dns; mail.domain.ltd
Arrival-Date: Sat, 4 May 2024 07:51:36 +0300

Final-Recipient: RFC822; catav@domain.ltd
Action: failed
Status: 4.4.7
Diagnostic-Code: SMTP; 403 4.7.0 TLS handshake failed.
Last-Attempt-Date: Sat, 4 May 2024 13:56:24 +0300


Return-Path: <zeki@bdomain.ltd>
Received: from dummy.faircode.eu (host-91-93-141-117.reverse.superonline.net [x.x.x.x] (may be forged))
	(authenticated bits=0)
	by mail.domain.ltd (8.14.4/8.14.4) with ESMTP id 4444pZcB016399
	(version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NOT)
	for <catav@domain.ltd>; Sat, 4 May 2024 07:51:36 +0300
DKIM-Filter: OpenDKIM Filter v2.11.0 mail.domain.ltd 4444pZcB016399
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=bdomain.ltd; s=dkim;
	t=1714798296; bh=51oLmqf/ISY4Fii9coolQN58GP3ttNZYv7REEU6aqU4=;
	h=Date:From:To:Subject:From;
	b=lI4XVjLqxPbvCRJ2jcr9HJ7jHANQtp7eVDr76wdLVFcwaeyQnLTmX9JMy6CoCTISi
	 go38SUlYlQsFTX1BeZjg9sjZ3hO/48VQ28UKluElRIBu2/V/Ea2teZhu7B2MVakeSt
	 63DuQtv0cRS/Qfd266FBRS6EpUX8L1w9q1wF1nCM=
Date: Sat, 4 May 2024 07:51:36 +0300 (GMT+03:00)
From: =?UTF-8?Q?Zeki = <zeki@bdomain.ltd>
To: =?UTF-8?Q?Zeki= <catav@domain.ltd>
Message-ID: <be5bf6df-bd45-4021-8316-b4f6ee452a47@bdomain.ltd>
Subject: Test
MIME-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_1_37327088.1714798296872"
X-Correlation-ID: <be5bf6df-bd45-4021-8316-b4f6ee452a47@bdomain.ltd>
X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (mail.domain.ltd [x.x.x.x]); Sat, 04 May 2024 07:51:36 +0300 (+03)
X-Spam-Status: No, score=-1.0 required=10.0 tests=ALL_TRUSTED,HTML_MESSAGE,
	TVD_SPACE_RATIO autolearn=disabled version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mail.domain.ltd
X-Virus-Scanned: clamav-milter 0.100.3 at mail.domain.ltd
X-Virus-Status: Clean

Thanks.

Soooo let’s look at

sudo python3 -c "import OpenSSL; print(OpenSSL)"

and

sudo ls -l /usr/lib/python3/dist-packages/OpenSSL/

and

sudo dpkg -L python3-openssl

sudo python3 -c “import OpenSSL; print(OpenSSL)”

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'OpenSSL'

sudo ls -l /usr/lib/python3/dist-packages/OpenSSL/

ls: cannot access '/usr/lib/python3/dist-packages/OpenSSL/': No such file or directory

sudo dpkg -L python3-openssl


/.
/usr
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/OpenSSL
/usr/lib/python3/dist-packages/OpenSSL/SSL.py
/usr/lib/python3/dist-packages/OpenSSL/__init__.py
/usr/lib/python3/dist-packages/OpenSSL/_util.py
/usr/lib/python3/dist-packages/OpenSSL/crypto.py
/usr/lib/python3/dist-packages/OpenSSL/debug.py
/usr/lib/python3/dist-packages/OpenSSL/rand.py
/usr/lib/python3/dist-packages/OpenSSL/version.py
/usr/lib/python3/dist-packages/pyOpenSSL-20.0.1.egg-info
/usr/lib/python3/dist-packages/pyOpenSSL-20.0.1.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/pyOpenSSL-20.0.1.egg-info/dependency_links.txt
/usr/lib/python3/dist-packages/pyOpenSSL-20.0.1.egg-info/requires.txt
/usr/lib/python3/dist-packages/pyOpenSSL-20.0.1.egg-info/top_level.txt
/usr/share
/usr/share/doc
/usr/share/doc/python3-openssl
/usr/share/doc/python3-openssl/changelog.Debian.gz
/usr/share/doc/python3-openssl/changelog.gz
/usr/share/doc/python3-openssl/copyright

So let’s try

sudo apt install python3-openssl --reinstall

and hopefully validate that it fixed the issue

(sudo ls -l /usr/lib/python3/dist-packages/OpenSSL/ should then not report an error but a list of files)

Hi Aleks,
Thanks, solved.