官网: https://pypi.org/project/mysqlclient/
macOS(自制)
安装 MySQL 和 mysqlclient:
# Assume you are activating Python 3 venv $ brew install mysql $ pip install mysqlclient
如果不想安装 MySQL 服务器,可以使用 mysql-client 代替:
# Assume you are activating Python 3 venv $ brew install mysql-client $ echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile $ export PATH="/usr/local/opt/mysql-client/bin:$PATH" $ pip install mysqlclient
执行完了之后发现不好使,还是报错:
解决方法是:
执行语句: PATH="$PATH":/usr/local/mysql/bin
再次安装就好使了,特此记录下。