Reputation: 1
Request Method: POST
Request URL: http://192.168.0.110/admin/login/?next=/admin/
Django Version: 4.0.1
Exception Type: RuntimeError
Exception Value:
'cryptography' package is required for sha256_password or caching_sha2_password auth methods
Exception Location: /home/chickoos/explab/ExpLab/venv/lib/python3.8/site-packages/pymysql/_auth.py, line 143, in sha2_rsa_encrypt
Python Executable: /home/chickoos/explab/ExpLab/venv/bin/python
Python Version: 3.8.10
Python Path:
['/home/chickoos/explab/ExpLab',
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
'/home/chickoos/explab/ExpLab/venv/lib/python3.8/site-packages']
Server time:
Upvotes: 0
Views: 4984
Reputation: 7987
So in my case, which suddenly gave me this error out of the blue, i figured it out. I forgot my root password in MySql under MacOSX, which to initialize it - we need to go to system preferences -> MySQL -> initialize DB
It ofc remove everything i had before, but it appears it gave me 2 choices that I missed the first time.
[*] Use Strong Password Encryption
MySQL 8 supports a newer, stronger authentication method. All new
installations should use this method, but older connectors and clients may be
unable to connect.
Or
[ ] Use Legacy Password Encryption
The legacy authentication method should only be used when compatibility with
MySQL 5.x connectors or clients is required.
For some reason I went with the default, and this resulted the exception when I tried to connect:
RuntimeError: 'cryptography' package is required for sha256_password or caching_sha2_password auth methods
So it wasn't a python lib that was the issue, it hit me, because this error also appears when you use the UI and try to connect, suddenly i saw the same error ( which i missed also and just clicked "continue" ).
To solve it, i initialized it again ( and removed all tables ) by going to
system preferences -> MySQL -> initialize DB
and chose "Legacy Password"
Upvotes: 0
Reputation: 798
To use “sha256_password” or “caching_sha2_password” for authenticate, you need to install additional dependency:
$ python3 -m pip install PyMySQL[rsa]
According to official documentation: https://pymysql.readthedocs.io/en/latest/user/installation.html
Upvotes: 1