MySQLdb is an interface for Python Mysql database link
Mounting terminal can command MySQLdb
pip3 install MySQLdb-python
But an error occurs, the reason for the error
:mysql_config not found
This is because in the configuration file, mysql can not find the configuration file cause, which is mysql_config
Solution:
MySQLdb manually download the package, download links: https://pypi.org/project/MySQL-python/#files
Find the configuration file "site.cfg" After decompression, find
#mysql_config = / usr / local / bin / mysql_config
removed note #, change to the correct path and the installation configuration file mysql
mysql_config = / usr / local / mysql / bin / mysql_config
Then in the terminal, just before entering the folder where you find site.cfg
Run the installation command
sudo python3 setup.py install
Then that is another error
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun error: command 'gcc' failed with exit status 1
Find the folder Developer, almost nothing was found inside stuff, then I know mac xcode will be deleted after the reinstall the system needs to be reinstalled
xcode-select --install
Installation command after a successful run of MySQLdb
sudo python3 setup.py install
Or error, going crazy
sudo easy_install mysql-python Password: Searching for mysql-python Reading http://pypi.python.org/simple/mysql-python/ Reading http://sourceforge.net/projects/mysql-python/ Reading http://sourceforge.net/projects/mysql-python Best match: MySQL-python 1.2.3 Downloading http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f Processing MySQL-python-1.2.3.tar.gz Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-UoZlf7/MySQL-python-1.2.3/egg-dist-tmp-phaQqE warning: no files found matching 'MANIFEST' warning: no files found matching 'ChangeLog' warning: no files found matching 'GPL' clang: warning: argument unused during compilation: '-mno-fused-madd' _mysql.c:36:10: fatal error: 'my_config.h' file not found #include "my_config.h" ^ 1 error generated. error: Setup script exited with error: command 'clang' failed with exit status 1 ninjaiimac:MySQL-python-1.2.3 sunninjaisun$
Less than searching out the method, finally the Great God stackoverflow
brew install mysql brew unlink mysql brew install mysql-connector-c sed -i -e 's/libs="$libs -l "/libs="$libs -lmysqlclient -lssl -lcrypto"/g' /usr/local/bin/mysql_config pip install MySQL-python brew unlink mysql-connector-c brew link --overwrite mysql
Operating meal fierce as a tiger, and then continue with the original installation command
In fact it is not enough, but on several of these commands, follow the prompts to try one or two are successful, although there are the wrong format, but has not hampered.
In pycharm finally did in MySQLdb below the red wavy line.