miniconda3: AttributeError: module ‘cryptography.hazmat.backends’ has no attribute ‘openssl’
- AttributeError: module ‘cryptography.hazmat.backends’ has no attribute ‘openssl’
-
-
- Solution
-
AttributeError: module cryptography.hazmat.backends’ has no attribute openssl’
The problem occurred after miniconda3 in the AUR was updated to 23.5.2-1 (before and after the update, I commented out the conda in .bashrc
according to the instructions). At that time, after the update, I went to read the AUR comments and found nothing. After two days of system upgrade, the bug was still there. After taking CPR on the third day, I looked at the comment area and found a possible solution
gru: solved it by activating the base conda env and updating with pip pyopenssl and cryptography
However I try conda activate base
and get the same error
[mifen@hp ~]$ conda env list Traceback (most recent call last): File "/opt/miniconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 16, in __call__ return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/cli/main.py", line 70, in main_subshell p = generate_parser() ^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/cli/conda_argparse.py", line 65, in generate_parser p = ArgumentParser( ^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/cli/conda_argparse.py", line 152, in __init__ self._subcommands = context.plugin_manager.get_hook_results("subcommands") ^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/base/context.py", line 502, in plugin_manager from ..plugins.manager import get_plugin_manager File "/opt/miniconda3/lib/python3.11/site-packages/conda/plugins/__init__.py", line 3, in <module> from .hookspec import hookimpl # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/plugins/hookspec.py", line 9, in <module> from .types import CondaSolver, CondaSubcommand, CondaVirtualPackage File "/opt/miniconda3/lib/python3.11/site-packages/conda/plugins/types.py", line 7, in <module> from ..core.solve import Solver File "/opt/miniconda3/lib/python3.11/site-packages/conda/core/solve.py", line 41, in <module> from .index import _supplement_index_with_system, get_reduced_index File "/opt/miniconda3/lib/python3.11/site-packages/conda/core/index.py", line 24, in <module> from .subdir_data import SubdirData, make_feature_record File "/opt/miniconda3/lib/python3.11/site-packages/conda/core/subdir_data.py", line 53, in <module> from ..trust.signature_verification import signature_verification File "/opt/miniconda3/lib/python3.11/site-packages/conda/trust/signature_verification.py", line 12, in <module> from conda_content_trust.authentication import verify_delegation, verify_root File "/opt/miniconda3/lib/python3.11/site-packages/conda_content_trust/authentication.py", line 34, in <module> from .common import ( File "/opt/miniconda3/lib/python3.11/site-packages/conda_content_trust/common.py", line 66, in <module> import cryptography.hazmat.backends.openssl.ed25519 File "/opt/miniconda3/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/__init__.py", line 6, in <module> from cryptography.hazmat.backends.openssl.backend import backend File "/opt/miniconda3/lib/python3.11/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 61, in <module> from cryptography.hazmat.bindings.openssl import binding File "/opt/miniconda3/lib/python3.11/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 232, in <module> Binding.init_static_locks() File "/opt/miniconda3/lib/python3.11/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 206, in init_static_locks cls._ensure_ffi_initialized() File "/opt/miniconda3/lib/python3.11/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 195, in _ensure_ffi_initialized _legacy_provider_error(cls._legacy_provider_loaded) File "/opt/miniconda3/lib/python3.11/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 104, in _legacy_provider_error raise RuntimeError( RuntimeError: OpenSSL 3.0's legacy provider failed to load. This is a fatal error by default, but cryptography supports running without legacy algorithms by setting the environment variable CRYPTOGRAPHY_OPENSSL_NO_LEGACY. If you did not expect this error, you have likely made a mistake with your OpenSSL configuration. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/miniconda3/condabin/conda", line 13, in <module> sys. exit(main()) ^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/cli/main.py", line 129, in main return conda_exception_handler(main, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 376, in conda_exception_handler return_value = exception_handler(func, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 19, in __call__ return self. handle_exception(exc_val, exc_tb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 75, in handle_exception return self. handle_unexpected_exception(exc_val, exc_tb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 88, in handle_unexpected_exception self. print_unexpected_error_report(error_report) File "/opt/miniconda3/lib/python3.11/site-packages/conda/exception_handler.py", line 159, in print_unexpected_error_report from .cli.main_info import get_env_vars_str, get_main_info_str File "/opt/miniconda3/lib/python3.11/site-packages/conda/cli/main_info.py", line 15, in <module> from ..core.index import _supplement_index_with_system File "/opt/miniconda3/lib/python3.11/site-packages/conda/core/index.py", line 24, in <module> from .subdir_data import SubdirData, make_feature_record File "/opt/miniconda3/lib/python3.11/site-packages/conda/core/subdir_data.py", line 53, in <module> from ..trust.signature_verification import signature_verification File "/opt/miniconda3/lib/python3.11/site-packages/conda/trust/signature_verification.py", line 12, in <module> from conda_content_trust.authentication import verify_delegation, verify_root File "/opt/miniconda3/lib/python3.11/site-packages/conda_content_trust/authentication.py", line 34, in <module> from .common import ( File "/opt/miniconda3/lib/python3.11/site-packages/conda_content_trust/common.py", line 334, in <module> cryptography.hazmat.backends.openssl.ed25519._Ed25519PrivateKey, # DANGER ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'cryptography.hazmat.backends' has no attribute 'openssl'
Solution
Enter the bin directory under the conda installation directory, use the pip under it to delete the old version of the package, and then reinstall to install the new version
$ pwd /opt/miniconda3/bin $ ./pip list | grep pyOpenSSL pyOpenSSL 23.0.0 $ ./pip list | grep cryptography cryptography 39.0.1 $ sudo ./pip uninstall cryptography pyOpenSSL $ sudo ./pip install cryptography pyOpenSSL Successfully installed cryptography-41.0.3 pyOpenSSL-23.2.0 $ conda env list # conda environments: # 310 /home/mifen/.conda/envs/310 vpy /home/mifen/.conda/envs/vpy base /opt/miniconda3