0

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 which 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?

cafce25
  • 15,907
  • 4
  • 25
  • 31
Tiero
  • 1
  • 2
  • 1
    I'd guess your dependencies are installed per-user, and starting as a service executes as root (or whatever the analogous user is called in Windows). – Ivan C Aug 04 '23 at 19:54
  • Hi Ivan, thank you for your response. I tought the same, but there are not external dependencies.... I'm going crazy.... – Tiero Aug 07 '23 at 07:18

0 Answers0