Description
Hi i'm getting the error:
Traceback (most recent call last):
File "C:\Users--\OneDrive\Desktop\OneDrive Dump\Messenger v7.py", line 10, in
from cryptography.fernet import Fernet
File "C:\Users--\AppData\Roaming\Python\Python39\site-packages\cryptography\fernet.py", line 14, in
from cryptography.exceptions import InvalidSignature
File "C:\Users--\AppData\Roaming\Python\Python39\site-packages\cryptography\exceptions.py", line 9, in
from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
ImportError: DLL load failed while importing _rust: The specified procedure could not be found.
I have no clue how to fix this, I have tried installing cryptography in a virtual environment:
python -m venv myenv
myenv\Scripts\activate
pip install cryptography
I tried coping the - cryptography and cryptography-43.0.0.dist-info folder (from another laptop where cryptography works) onto this device, wich gives the same error on this device
I have tried going to the Rust website and installing it - I installed and verified with: rustc --version.
When compiling the code into exe (with auto-py-to-exe) it works on this devise.
I got this error when adding encryption to my code, the error also happens on smaller pieces of code so, to keep this short I will just show a small example program wich still gives the error. It is below:
from cryptography.fernet import Fernet
key = Fernet.generate_key()
cipher = Fernet(key)
message = "Test message."
encrypted_message = cipher.encrypt(message.encode())
decrypted_message = cipher.decrypt(encrypted_message).decode()
print(f"Original message: {message}")
print(f"Encrypted message: {encrypted_message}")
print(f"Decrypted message: {decrypted_message}")
OS:
Windows 10
Installed with:
pip install cryptography
I also tried:
pip install cryptography --no-binary cryptography
Help would be appreciated!
Versions:
Cryptography Version: 43.0.0
Python 3.9.0
pip 24.3.1
Setuptools Version: 75.6.0