Django DRF error DLL Load Failed while importing _rust in Python 3.11.3 venv in Windows Server 2022 with cryptography-43.0.1-cp39-abi3-win_amd64.whl
My code is working in local environment of windows10 with venv on Python 3.10.11. However, on deploying in Windows Server 2022 with Apache2 webserver with venv on Python 3.11.3 getting following error. I have trying upgrading, installing binary. Till now issue is not resolved. Can anyone help in getting the issue resolved?
other packages in problematic environment are cffi-1.17.1 cryptography-43.0.1 pycparser-2.22
from cryptography.hazmat.primitives.asymmetric import padding\r
File "C:\\cbsesb\\cbsenv\\Lib\\site-packages\\cryptography\\hazmat\\primitives\\asymmetric\\padding.py", line 9, in <module>\r
from cryptography.hazmat.primitives import hashes\r
File "C:\\cbsesb\\cbsenv\\Lib\\site-packages\\cryptography\\hazmat\\primitives\\hashes.py", line 9, in <module>\r
from cryptography.hazmat.bindings._rust import openssl as rust_openssl\r
ImportError: DLL load failed while importing _rust: The specified module could not be found.\r
Package Version
----------------------- ---------
asgiref 3.7.1
certifi 2023.7.22
cffi 1.17.1
charset-normalizer 3.3.2
cryptography 43.0.1
cx-Oracle 8.3.0
defusedxml 0.7.1
dicttoxml 1.7.16
Django 4.2.1
djangorestframework 3.14.0
djangorestframework-xml 2.0.0
idna 3.6
ldap3 2.9.1
lxml 4.9.3
mod-wsgi 4.9.4
pip 24.2
psycopg2 2.9.6
pyasn1 0.6.0
pycparser 2.22
pycryptodome 3.18.0
pyOpenSSL 24.2.1
pytz 2023.3
requests 2.31.0
setuptools 74.1.2
signxml 3.2.1
soupsieve 2.5
sqlparse 0.4.4
typing_extensions 4.6.1
tzdata 2023.3
urllib3 2.2.0
xmltodict 0.12.0
Tried to update the setup tools but did not worked
python -m pip install --upgrade pip setuptools
Tried to downgrade the Python to 3.10 but did not worked.
installing Rust doesn't work.
Tried installing binary for cryptography but did not worked.
python -m pip install cryptography --only-binary cryptography
The issue is related to the environment. This was resolved by removing the use of the package cryptography
. I avoided the issue by replacing it with the PyCryptodome
package. It worked perfectly in both environment.