Mac installation Python mysqlclient problems encountered and how to solve

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.