NameError: name ‘_mysql’ is not defined Mac M1

This solution worked for me for (NameError: name ‘_mysql’) using mysqlclient . If you are on M1 just create ~/.zshrc using vi ~/.zshrc if it doesn’t exist.

vi  ~/.zshrc 

and add the following:

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$PATH"

Make sure to end terminal process in vscode by clicking delete trash icon and then open terminal and run python runserver