mysql-shell python mode can't import cryptography modules
General
Escalation
General
Escalation
Description
Environment
None
Activity
Show:
Daniel Thorell February 25, 2024 at 4:51 PM
It’s enough to do:
mysqlsh --py -e "from cryptography.hazmat.primitives.ciphers import Cipher"
And it crashes with:
ModuleNotFoundError: No module named '_cffi_backend'
thread '<unnamed>' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.18.3/src/err/mod.rs:790:5:
Python API call failed
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/mysqlsh/lib/python3.9/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py", line 11, in <module>
from cryptography.hazmat.primitives.ciphers.base import (
File "/usr/lib/mysqlsh/lib/python3.9/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 10, in <module>
from cryptography.exceptions import (
File "/usr/lib/mysqlsh/lib/python3.9/site-packages/cryptography/exceptions.py", line 9, in <module>
from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
pyo3_runtime.PanicException: Python API call failed
Aaditya Dubey February 25, 2024 at 3:14 PM
Hi @Daniel Thorell
Thank you for the report.
Could you please share complete set of steps to repeat this behaviour locally?
Details
Details
Assignee
Aaditya Dubey
Aaditya DubeyReporter
Daniel Thorell
Daniel ThorellNeeds QA
Yes
Components
Affects versions
Priority
Smart Checklist
Open Smart Checklist
Smart Checklist

Open Smart Checklist
Created February 9, 2024 at 9:48 AM
Updated March 6, 2024 at 9:25 AM
When replacing mysql-community 8.0.34 with percona of the same version. Our python scripts do not work anymore due to:
from cryptography.hazmat.primitives.ciphers import Cipher ModuleNotFoundError: No module named '_cffi_backend' thread '<unnamed>' panicked at /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.18.3/src/err/mod.rs:790:5: Python API call failed note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Traceback (most recent call last): File "<string>", line 1, in <module> File "/usr/lib/mysqlsh/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/__init__.py", line 11, in <module> from cryptography.hazmat.primitives.ciphers.base import ( File "/usr/lib/mysqlsh/lib/python3.11/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 10, in <module> from cryptography.exceptions import ( File "/usr/lib/mysqlsh/lib/python3.11/site-packages/cryptography/exceptions.py", line 9, in <module> from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions pyo3_runtime.PanicException: Python API call failed
Also tried with the latest:
Package: percona-mysql-shell
Version: 8.0.35-1-1.jammy