Configure pythonmysql development environment python in macOSX
1. first download and install mysql ,:
Http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.19.tar.gz
Decompress:
Tar-xzvf mysql-5.6.19.tar.gz
Download gmock and use it to compile mysql:
Https://googlemock.googlecode.com/files/gmock-1.7.0.zip
Decompress the package to the specified directory.
unzip gmock-1.6.0.zip -d mysql-5.6.19/source_downloads
Go to the mysql source directory:
Cd myslq-5.6.19
Run:
Cmake.
Make
Make install
It may take more than 10 minutes to complete compilation and installation.
You can also use brew install mysql -- universal, but this command seems to be unavailable recently.
2. download and install mysql-python
Https://pypi.python.org/pypi/MySQL-python/1.2.5
After decompression, modify the site. cfg file:
Find this line:
# Mysql_config =/usr/local/bin/mysql_config
Remove the comment and change it:
Mysql_config =/usr/local/mysql/bin/mysql_config
Specify the path of the mysql_config file on your machine.
You can run the find/-name mysql_config command to confirm that if your mysql installation path is different from that in this article, the actual path prevails.
Then, execute:
Sudo python setup. py install
3. after the installation is successful, go to the python command line and enter
Import MySQLdb
An error occurs:
Library not loaded: libmysqlclient.18.dylib
This is because python cannot find the mysql path. run:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
After creating a soft link, you can solve this problem.