NameError: name '_mysql' is not defined in Python (Django) (Especially During Local Development)
DjangoMySQLPython
2020-10-11 02:52 (6 years ago)
I tried to start a Django project that had been working fine before, but after a long time, I encountered the following error:
version_info, _mysql.version_info, _mysql.__file__
NameError: name '_mysql' is not defined
If this happens, it means the project won't start.
This issue is caused by an update to the MySQL library outside of the Python project, which breaks the link from the mysqlclient within the project.
This is likely due to running a command like brew install mysql-client.
You can resolve this issue by reinstalling mysqlclient.
pip install --force-reinstall mysqlclient
Please rate this article (No signup or login required)
Current rating: 4.3 (6)
Related posts
Fix: symbol not found in flat namespace '_mysql_affected_rows' when importing MySQLdb on Apple Silicon
Fix: pip install mysqlclient fails with ld: library not found for -lzlib on M2 Mac (MYSQLCLIENT_LDFLAGS)
When Installing python mysqlclient, ld: library not found for -lzstd Error Occurs
When Setting the Path for mysql-client Installed via Homebrew on macOS, It Automatically Follows Version Changes
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.