python安装MySQL-python错误

1. 安装

$ brew install mysql-connector-c
$ pip install MySQL-python

2. 可能的错误

Collecting MySQL-python

Downloading MySQL-python-1.2.5.zip (108kB)

100% |████████████████████████████████| 112kB 299kB/s 

Complete output from command python setup.py egg_info:

Traceback (most recent call last):

File "", line 1, in 

File "/private/tmp/pip-build-poWpwy/MySQL-python/setup.py", line 17, in 

metadata, options = get_config()

File "setup_posix.py", line 53, in get_config

libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]

File "setup_posix.py", line 8, in dequote

if s[0] in "\"'" and s[0] == s[-1]:

IndexError: string index out of range



----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-poWpwy/MySQL-python/>

3. 解决

修改这个文件 /usr/local/bin/mysql_config

#Create options
Libs = "-L $ pkglibdir "
Libs = " $ libs   -l"

修改为:

#Create options
Libs = "- L $ pkglibdir"
Libs = "$ libs -lmysqlclient -lssl -lcrypto"

最后重新执行安装:

pip install mysql-python

原文参考这里

你可能感兴趣的:(python安装MySQL-python错误)