Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
716 views
in Technique[技术] by (71.8m points)

python - "cryptography is required for sha256_password or caching_sha2_password"

Good day. Hope your all are well. Can someone help me with fix this?

I'm new to the MySQL environment. I'm trying to connect to MySQL Database remotely. I used the following python code and got this error.

Print(e) = "cryptography is required for sha256_password or 
             caching_sha2_password"

And have no idea how to solve the error.

import pymysql as db

HOST = "XXXXX.XXX.XX”
PORT = XXXX
USER = "my_username"
PASSWORD = "my_password”
DB = "db_name"

try:
    connection = db.Connection(host=HOST, port=PORT,user=USER,                 
    passwd=PASSWORD, db=DB)

    dbhandler = connection.cursor()
    dbhandler.execute("SELECT * from table_name")
    result = dbhandler.fetchall()
    for item in result:
        print (DB)
 except Exception as e:
    print(e)

finally:
    connection.close()
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

pip install cryptography

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...