Python3 MySql

安装mysqlclient报错解决方法

pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-1.3.12.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "", line 1, in 
      File "/private/var/folders/_f/32zb1zbj429dn0psm2g07znw0000gn/T/pip-build-d87s1lxe/mysqlclient/setup.py", line 17, in 
        metadata, options = get_config()
      File "/private/var/folders/_f/32zb1zbj429dn0psm2g07znw0000gn/T/pip-build-d87s1lxe/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/_f/32zb1zbj429dn0psm2g07znw0000gn/T/pip-build-d87s1lxe/mysqlclient/setup_posix.py", line 54, in 
        libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
      File "/private/var/folders/_f/32zb1zbj429dn0psm2g07znw0000gn/T/pip-build-d87s1lxe/mysqlclient/setup_posix.py", line 12, 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/var/folders/_f/32zb1zbj429dn0psm2g07znw0000gn/T/pip-build-d87s1lxe/mysqlclient/
1.找到 mysql_config 文件 (目录:   /usr/local/Cellar/mysql-connector-c/6.1.11/bin/)
# 修改前先备份
cp  mysql_config mysql_config.backup

# 使用vi修改配置文件
sudo vi mysql_config

# 114 gg跳转到 114行

将
> # Create options 
> libs="-L$pkglibdir"
> libs="$libs -l "

替换为

> # Create options 
> libs="-L$pkglibdir"
> libs="$libs -lmysqlclient -lssl -lcrypto"
保存!!!!

重新运行

pip3 install mysqlclient

成功

你可能感兴趣的:(Python3 MySql)