mac pip install MySQL-python IndexError: string index out of range
pip install mysql
Collecting mysql
Downloading https://files.pythonhosted.org/packages/06/ef/c4efbf2a51fb46aba9be03a973638d9539c9ca10a5259b2cbb1a66133b2e/mysql-0.0.1.tar.gz
Collecting MySQL-python (from mysql)
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/zn/t8xxx4m149s9jqp1810ndrz80000gn/T/pip-install-oHMKPE/MySQL-python/setup.py", line 17, in <module>
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
尝试了各种网上的报错都不管用:
安装mysql-connector-c:
brew install mysql-connector-c
- 1
安装 xcode select
xcode-select --install
- 1
最终找到解决方法:
修改mysql配置文件:mysql_config
ls -al \`which mysql_config\`
lrwxr-xr-x 1 xxxxx xxxxx 51B 7 3 16:19 /usr/local/bin/mysql_config@ \-\> \../Cellar/mysql-connector-c/6.1.11/bin/mysql_config
cd \`dirname ../Cellar/mysql-connector-c/6.1.11/bin/mysql_config`
cp mysql_config mysql_config_bak
- 1
- 2
- 3
- 4
执行:vim mysql_config,搜索 libs,或者114行,替换为115行即可
112 # Create options
113 libs=”-Lpkglibdir”
114 #libs=”pkglibdir” 114 #libs=”libs -l ” ##源代码
115 libs=”$libs -lmysqlclient -lssl -lcrypto ” ##修改成这样