[Python|Django] mysqlclient安装

1,152 阅读1分钟

使用的是Python3.5,使用Django配置数据库时,需要安装mysql驱动

使用pip安装

pip3 install mysqlclient

报错如下

Command "python setup.py egg_info" failed with error code 1

解决如下

  1. brew install mysql-connector-c

  2. 修改mysql_config

文件位于 which mysql_config

原本的mysql_config文件

# Create config
libs="-L$pkglibdir"
libs="$libs -l "

修改为:

# Create options 
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
  1. brew info openssl

  2. 最终 pip3 install mysqlclient