"cryptography is required for sha256_password or caching_sha2_password" "cryptography is required for sha256_password or caching_sha2_password" python python

"cryptography is required for sha256_password or caching_sha2_password"


The error message can be made more comprehensive and helpful. In order to fix this "cryptography" package needs to be installed.

pip install cryptography


To use “sha256_password” or “caching_sha2_password” for authenticate, you need to install additional dependency:

$ python3 -m pip install PyMySQL[rsa]

Source: https://pymysql.readthedocs.io/en/latest/user/installation.html


For what it's worth, I had this problem today using MySQL via SQLAlchemy in Python. It turned out that I was using the wrong password for this account. In other words, if you have this problem, you might want to start by just confirming that you're using the correct password.

FWIW, I am not sure why this generated a cryptography message. Something buggy along the way?