Install Mysqlclient on Mac encountered some problems, find data many people have encountered the same problem. Through the data and experiments, succeeded. Here is a record of the hope to help people who have met the same problem.
I use Python3, the installation steps are as follows:
Brew Install MYSQL-CONNECTOR-CPIP3 Install Mysqlclient
An error occurred while executing PIP3 install Mysqlclient:
? /usr/local/cellar/mysql-connector-c/6.1.11/bin >pip3 Install mysqlclientcollecting mysqlclient Using Cached mysqlclient-1.3.12.tar.gz complete output from command python setup.py egg_info:traceback (most recent call last): File "<string>", line 1, in <module> file "/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/t/ pip-build-f9admsgv/mysqlclient/setup.py ", line page, in <module> metadata, options = Get_config () File"/p Rivate/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/t/pip-build-f9admsgv/mysqlclient/setup_posix.py ", line 54, in get_config libraries = [Dequote (i[2:]) for I in Libs if I.startswith ('-l ')] File "/PRIVATE/VAR/FOLDERS/2W/5 6bgkvqd1xldl56fx_gx_fg00000gn/t/pip-build-f9admsgv/mysqlclient/setup_posix.py ", line Si, in <listcomp> librar ies = [Dequote (i[2:]) for I in Libs if I.startswith ('-l ')] File "/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000 Gn/t/pip-build-f9admsgv/mysqlclient/setup_posix.py ", line, in Dequote if s[0] in" \ "" "and s[0] = = S[-1]: Indexerror:string index out of range---- ------------------------------------
Solution: Mysql_config (BIN)
Execute: Vim mysql_config, search for Libs, or 114 lines, replace with 115 lines
# Create options113 libs= "-l$pkglibdir" #libs = "$libs-l" # #源代码115 libs= "$libs-lmysqlclient-lssl-lcrypto"
# #修改成这样
Execute PIP3 install mysqlclient again and succeed. As shown below:
? /usr/local/cellar/mysql-connector-c/6.1.11/bin >pip3 Install mysqlclientcollecting mysqlclient Using Cached Mysqlclient-1.3.12.tar.gzbuilding Wheels for collected packages:mysqlclient Running setup.py bdist_wheel for Mysqlclient. Done Stored in directory:/users/kk/library/caches/pip/wheels/df/bb/60/ Bf7c315cbe163515db1c846e4ffa5557dd785c82e82f3492e8successfully built mysqlclientinstalling collected packages: Mysqlclientsuccessfully installed mysqlclient-1.3.12
Mac installation Python mysqlclient problems encountered and how to solve