NameError: name '_mysql' is not defined in Python (Django) (Especially During Local Development)

Django MySQL Python
2020-10-11 11:52 (4 years ago) ytyng

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
Current rating: 4.3

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011