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:
Install mysql-connector-Install mysqlclient
An error occurred while executing PIP3 install Mysqlclient:
? /usr/local/cellar/mysql-connector-c/6.1. One/bin >PIP3Installmysqlclientcollecting mysqlclient Using Cached Mysqlclient-1.3. A.Tar. GZ complete output from command python setup.py egg_info:traceback (most recent call Last): File"<string>", line1,inch<module>File"/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/t/pip-build-f9admsgv/mysqlclient/setup.py", line -,inch<module>metadata, Options=get_config () File"/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/t/pip-build-f9admsgv/mysqlclient/setup_posix.py ", line Wu,inchGet_config Libraries= [Dequote (i[2:]) forIinchLibsifI.startswith ('- L')] File"/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/t/pip-build-f9admsgv/mysqlclient/setup_posix.py ", line Wu,inch<listcomp>Libraries= [Dequote (i[2:]) forIinchLibsifI.startswith ('- L')] File"/private/var/folders/2w/56bgkvqd1xldl56fx_gx_fg00000gn/t/pip-build-f9admsgv/mysqlclient/setup_posix.py ", line A,inchDequoteifs[0]inch "\ "'"and s[0] = = s[-1]: indexerror:stringindex out of range----------------------------------------
Solution: Mysql_config
Execute: Vim mysql_config, search for Libs, or 114 lines, replace with 115 lines
the # Create Options 113 libs="-l$pkglibdir"#libs = "$libs-l" # #源代码 libs= "$libs-lmysqlclient-lssl-lcrypto" # #修改成这样
Execute PIP3 install mysqlclient again and succeed. As shown below:
? /usr/local/cellar/mysql-connector-c/6.1. One/bin >PIP3Installmysqlclientcollecting mysqlclient Using Cached Mysqlclient-1.3. A.Tar. Gzbuilding Wheels forcollected packages:mysqlclient Running setup.py bdist_wheel forMysqlclient ... DoneStoredinchDirectory:/users/kk/library/caches/pip/wheels/DF/bb/ -/bf7c315cbe163515db1c846e4ffa5557dd785c82e82f3492e8successfully built mysqlclientinstalling collected packages: Mysqlclientsuccessfully installed Mysqlclient-1.3. A
Mac installation Python mysqlclient problems encountered and how to solve