From cryptography.hazmat.bindings._rust import ( ImportError: DLL load failed while importing _rust: The specified procedure could not be found

Hi, I’ve encountered this error while first trying to train my rasa model. I have ensured that I’ve implemented this in a virtual environment, checked the compatibility of the python version (3.9) and my pip version (20.2.3). It seems like rasa had been properly installed, but this error seems to persist.

Any assistance on this would be deeply appreciated! Thank you.

This is the full traceback call-

Traceback (most recent call last): File “C:\Users\MuhammedMuzzammil\AppData\Local\Programs\Python\Python39\lib\runpy.py”, line 197, in run_module_as_main return run_code(code, main_globals, None, File “C:\Users\MuhammedMuzzammil\AppData\Local\Programs\Python\Python39\lib\runpy.py”, line 87, in run_code exec(code, run_globals) File "C:\Users\MuhammedMuzzammil\Desktop\Again\venv\Scripts\rasa.exe_main.py", line 7, in File "c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa_main.py", line 133, in main cmdline_arguments.func(cmdline_arguments) File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\cli\scaffold.py”, line 238, in run init_project(args, path) File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\cli\scaffold.py”, line 132, in init_project print_train_or_instructions(args) File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\cli\scaffold.py”, line 64, in print_train_or_instructions training_result = rasa.train( File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\api.py”, line 103, in train from rasa.model_training import train File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\model_training.py”, line 7, in import rasa.engine.validation File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\engine\validation.py”, line 33, in from rasa.engine.constants import RESERVED_PLACEHOLDERS File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\engine\constants.py”, line 3, in from rasa.core.channels import UserMessage File "c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\core\channels_init.py", line 3, in from rasa.core.channels.channel import ( # noqa: F401 File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\rasa\core\channels\channel.py”, line 4, in import jwt File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\jwt_init_.py”, line 1, in from .api_jwk import PyJWK, PyJWKSet File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\jwt\api_jwk.py”, line 7, in from .algorithms import get_default_algorithms, has_crypto, requires_cryptography File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\jwt\algorithms.py”, line 12, in from .utils import ( File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\jwt\utils.py”, line 7, in from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\cryptography\hazmat\primitives\asymmetric\ec.py”, line 11, in from cryptography.hazmat._oid import ObjectIdentifier File “c:\users\muhammedmuzzammil\desktop\again\venv\lib\site-packages\cryptography\hazmat_oid.py”, line 7, in from cryptography.hazmat.bindings._rust import ( ImportError: DLL load failed while importing _rust: The specified procedure could not be found.

Version details-

Rasa Version : 3.6.16 Minimum Compatible Version: 3.5.0 Rasa SDK Version : 3.6.2 Python Version : 3.9.0 Operating System : Windows-10-10.0.22621-SP0 Python Path : c:\users\muhammedmuzzammil\desktop\again\venv\scripts\python.exe

1 Like

Update: I’ve found the solution to this problem!

The issue was in the cryptography package and after looking at the latest release notes, I’ve noticed that the cryptography version needs to be updated. So, if your current version is 41.0.2 => Please upgrade it to 41.0.7 (This is the latest version currently)

Hope this helps others if they encounter this issue :slight_smile:

2 Likes

Encountering an ImportError like “DLL load failed while importing _rust” can be a challenging but enriching part of the learning curve in programming. It’s an opportunity to delve deeper into how libraries and their dependencies work within your system. Such issues often push us to explore and understand our development environment better, leading to a more robust skill set. For solutions and guidance through such technical hurdles, turning to communities or resources like https://theextensionofyou.cоm/ can be incredibly beneficial. These platforms often provide insights and support that can transform these obstacles into stepping stones towards becoming a more proficient developer. Remember, every error is a learning opportunity waiting to be unraveled!

This problem seems to persist and i have the latest version of cryptography and new on rasa can i get some help on how to persue his problem

I have the latest version now but the problem seems to persist what could be the reason

Hi @kobi003, Did you try to lower the cryptography module version?

Type the command: pip install cryptography==41.0.7

Note: This is assuming that your current rasa version is 3.6.15

Let me know if this works! If not, please feel free to get back to this thread with the error it’s showing. Have a good day :slight_smile:

My rasa version is 3.9.0 i dont know if that is the problem because i installed cryptography 41.7.0 already but the same error keeps showing

@muzzammil rasa version is 3.9 and cryptography version is 41.7.0 and still the error pops up i havent yet realized the problem brother

@nik202

41.0.7 @muzzammil

Then could you please copy paste the error message you are receiving so that I can help you better?

Could you please cross check your rasa version again too, 3.8 is the latest version the last time I checked.

(venv) PS C:\Users\MBAROUK\PycharmProjects\Chatbot\driCourse> rasa train C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\core\tracker_store.py:1044: MovedIn20Warning: Deprecated API features detected! These feat ure(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to “sqlalc hemy<2.0”. Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings. Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silen ce this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9) Base: DeclarativeMeta = declarative_base() 2024-04-30 15:20:14 INFO rasa.cli.train - Started validating domain and training data… 2024-04-30 15:21:10 INFO rasa.validator - Validating intents… 2024-04-30 15:21:10 INFO rasa.validator - Validating uniqueness of intents and stories… 2024-04-30 15:21:10 INFO rasa.validator - Validating utterances… C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\shared\utils\io.py:99: UserWarning: The action ‘utter_iamabot’ is used in the stories, but is not a valid utterance action. Please make sure the action is listed in your domain and there is a template defined with its name. More info at https://rasa.com/docs/rasa/actions#utterance-actions C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\shared\utils\io.py:99: UserWarning: The utterance ‘utter_bot’ is not used in any story or rule. 2024-04-30 15:21:10 INFO rasa.validator - Story structure validation… Processed story blocks: 100%|█████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<?, ?it/s, # trackers=1] 2024-04-30 15:21:10 INFO rasa.core.training.story_conflict - Considering all preceding turns for conflict analysis. 2024-04-30 15:21:10 INFO rasa.validator - No story structure conflicts found. Traceback (most recent call last): File “C:\Users\MBAROUK\AppData\Local\Programs\Python\Python39\lib\runpy.py”, line 197, in run_module_as_main return run_code(code, main_globals, None, File “C:\Users\MBAROUK\AppData\Local\Programs\Python\Python39\lib\runpy.py”, line 87, in run_code exec(code, run_globals) File "C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\Scripts\rasa.exe_main.py", line 7, in File "C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa_main.py", line 133, in main cmdline_arguments.func(cmdline_arguments) File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\cli\train.py”, line 61, in train_parser.set_defaults(func=lambda args: run_training(args, can_exit=True)) File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\cli\train.py”, line 101, in run_training training_result = train_all( File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\api.py”, line 103, in train from rasa.model_training import train File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\model_training.py”, line 7, in import rasa.engine.validation File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\engine\validation.py”, line 33, in from rasa.engine.constants import RESERVED_PLACEHOLDERS File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\engine\constants.py”, line 3, in from rasa.core.channels import UserMessage File "C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\core\channels_init.py", line 3, in from rasa.core.channels.channel import ( # noqa: F401 File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\core\channels\channel.py”, line 4, in import jwt File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\jwt_init_.py”, line 1, in from .api_jwk import PyJWK, PyJWKSet File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\jwt\api_jwk.py”, line 7, in from .algorithms import get_default_algorithms, has_crypto, requires_cryptography File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\jwt\algorithms.py”, line 12, in from .utils import ( File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\jwt\utils.py”, line 7, in from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurve File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\cryptography\hazmat\primitives\asymmetric\ec.py”, line 11, in from cryptography.hazmat._oid import ObjectIdentifier File “C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\cryptography\hazmat_oid.py”, line 9, in from cryptography.hazmat.bindings._rust import ( ImportError: cannot import name ‘ObjectIdentifier’ from ‘cryptography.hazmat.bindings.rust’ (C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\c ryptography\hazmat\bindings_rust_init.py) 2024-04-30 15:21:11 WARNING urllib3.connectionpool - Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken b y ‘NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x00000155A42A6DF0>: Failed to establish a new connection: [Errno 11001] getaddrinfo faile 2024-04-30 15:21:11 WARNING urllib3.connectionpool - Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken b y ‘NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x00000155A42C5340>: Failed to establish a new connection: [Errno 11001] getaddrinfo faile d’)‘: /api/2801673/envelope/ 2024-04-30 15:21:11 WARNING urllib3.connectionpool - Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken b y ‘NewConnectionError(’<urllib3.connection.HTTPSConnection object at 0x00000155A42D4610>: Failed to establish a new connection: [Errno 11001] getaddrinfo faile d’)': /api/2801673/envelope/ (venv) PS C:\Users\MBAROUK\PycharmProjects\Chatbot\driCourse> rasa --version C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\rasa\core\tracker_store.py:1044: MovedIn20Warning: Deprecated API features detected! These feat ure(s) are not compatible with SQLAlchemy 2.0. To prevent incompatible upgrades prior to updating applications, ensure requirements files are pinned to “sqlalc hemy<2.0”. Set environment variable SQLALCHEMY_WARN_20=1 to show all deprecation warnings. Set environment variable SQLALCHEMY_SILENCE_UBER_WARNING=1 to silen ce this message. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9) Base: DeclarativeMeta = declarative_base() Rasa Version : 3.6.19 Minimum Compatible Version: 3.5.0 Rasa SDK Version : 3.6.2 Python Version : 3.9.0 Operating System : Windows-10-10.0.19041-SP0 Python Path : C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\Scripts\python.exe

Python Version : 3.9.0

“from cryptography.hazmat.bindings._rust import ( ImportError: cannot import name ‘ObjectIdentifier’ from ‘cryptography.hazmat.bindings.rust’ (C:\Users\MBAROUK\PycharmProjects\Chatbot\venv\lib\site-packages\c ryptography\hazmat\bindings_rust_init.py) 2024-04-30

Is the error

Okay, from what I see it is in the cryptography library itself.

Could you please use the command: pip freeze > requirements.txt And send the content it produces, I just want to crosscheck the versions that have been currently installed.

The command displays nothing brother

Nothing is displayed when i initiate the command what could be the problem i am using pycharm @muzzamil

It won’t display anything in the terminal. As the command says, it creates a file called requirements.txt in your project’s directory. It will contain a list of all python packages and their versions which have been installed. Please send those details present inside that file.