DB Python Dev

[Python+MySQL] RuntimeError: cryptography is required

[Python+MySQL] RuntimeError: cryptography is required

RuntimeError: cryptography is required for sha256_password or caching_sha2_password

One day, trying to connect to MySQL from Python got this error.
This time we will introduce this cryptography is required error.

What error?

cryptography is required translates to" encryption ".

What you encrypt is password used for login.
If you use sha256_password orcaching_sha2_password when connecting to MySQL, you are saying to encrypt passwords.

As an aside, if you are regularly running a Python program from the Windows Task Manager, this cryptography is required may cause a(0x1) error, so be careful.

How to fix the error

The cause of the error is Python's cryptographic library shortage.
In other words, add the encryption library with the following command and solve it.

 pip install cryptography 

Improve helpfulness of error message when cryptography is required · Issue # 768 · PyMySQL / PyMySQL · GitHub

Notes on Windows environment

Access rejection error occurs depending on the folder where Python is installed under Windows environment.
Choose "Run as administrator" when starting the command prompt so that access is not refused.

 Right click -> Run as administrator 



駆け出し機械学習エンジニア。機械学習、DB、WEBと浅く広い感じ。 Junior machine learning engineer. Not a specialist but a generalist who knows DB, WEB too.

If you felt this article is useful, please share.

にほんブログ村 IT技術ブログへ

-DB, Python, Dev
-, ,

Translate »

Copyright© ITips , 2020 All Rights Reserved.