Try to install via PIP in a virtual environment:
pip install mysqlclient
And then an error is reported: oserror: MySQL_ config not found
Find official documents https://github.com/PyMySQL/mysqlclient-python , explaining that another module needs to be installed before installation:
brew install mysql-connector-c
But the report is wrong:
Check the error information before installing mysql-connector-c
brew unlink mysql
However, if you continue to install, you will still report an error:
Check the official instructions, the original MAC OS will need to MySQL_ In config
# on macOS, on or about line 112:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
Change to
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
Now it’s easy to do. Let’s go straight
which mysql_config
Find the file path, move to the path, modify the content with VIM, exit and re execute
pip install mysqlclient
And it worked.
In fact, there are other modules connected to MySQL under python, such as pymysql, etc. It’s not so troublesome to install under Mac.
The above is the whole content of this article, I hope to help you learn, and I hope you can support developer more.