[Cryptography-dev] Python cryptography fails to load due to _rust DDL import error

Gualtiero Scotti tierox at gmail.com
Fri Aug 4 11:20:36 EDT 2023


I'm struggling with this issue from few days...

I've a Python application that can run in two ways:

   - Stand alone -> launched directly using the python interpreter
   - From a windows service -> wrapping application with pywin32 and using
   the same interpreter

When app starts in standalone mode it works fine but when starts through
Windows service it fails with the following stackTrace:

.............................
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
File "C:\Program Files
(x86)\...\Python\Lib\site-package\cryptography\hazmat\primitives\kdf\pbkdf2.py",
line 10, in <module>
from cryptography.exceptions import (
File "C:\Program Files
(x86)\...\Python\Lib\site-packages\cryptography\exceptions.py", line
9, in <module>
from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
ImportError: DLL load failed while importing _rust: The specified
module could not be found."

I' don't know wich DLLs cryptography uses.....maybe they are not in
librarypath???

   - Python 3.11.3 32-bit
   - Windows 11

Requirements.txt

pywin32==305 pywin32-ctypes~=0.2.0 Flask~=2.1.2 flask-login~=0.6.1
Werkzeug~=2.0.2 waitress~=2.1.2 websockets~=10.3 transitions~=0.8.11
bitstruct~=8.15.1 PyYAML~=6.0 passlib~=1.7.4 dacite~=1.5.1 paho-mqtt~=1.6.1
setuptools~=60.2.0 six~=1.16.0 MarkupSafe~=2.1.1 click~=8.1.3
itsdangerous~=2.1.2 Jinja2~=3.1.2 pythonnet~=3.0.1 requests~=2.29.0
pyserial~=3.5.0 zeep~=4.2.1 *cryptography~=41.0.2* pycryptodome~=3.18.0

Did someone have the same issue? Any suggestion is appreciated.

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/cryptography-dev/attachments/20230804/05b0d6b7/attachment.html>


More information about the Cryptography-dev mailing list