尝试各路方法一直失败,最终找到一种办法
一、第一步安装 mysql-client
brew install mysql-client
二、第二步配置mysql-client的环境
找到刚才安装mysql-client的安装路径:
/opt/homebrew/Cellar/mysql-client/8.0.31/bin
mac一般就是上述路径,顶多切换下版本号8.0.31
3.在默认的~路径下打开.zshrc,配置环境
4.export PATH=“/opt/homebrew/Cellar/mysql-client/8.0.31/bin:$PATH”
5.control+s保存即可退出
三、使用pip3.10安装 mysqlclient
报错:
error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [16 lines of output] /bin/sh: mysql_config: command not found /bin/sh: mariadb_config: command not found /bin/sh: mysql_config: command not found Traceback (most recent call last): File "", line 2, in File "", line 34, in File "/private/var/folders/0k/cvjzhpyn24q2pcd9f9nbry640000gn/T/pip-install-8ny0s_zx/mysqlclient_45df0dcbeeaf46b3ae603aea98f6528d/setup.py", line 15, in metadata, options = get_config() File "/private/var/folders/0k/cvjzhpyn24q2pcd9f9nbry640000gn/T/pip-install-8ny0s_zx/mysqlclient_45df0dcbeeaf46b3ae603aea98f6528d/setup_posix.py", line 70, in get_config libs = mysql_config("libs") File "/private/var/folders/0k/cvjzhpyn24q2pcd9f9nbry640000gn/T/pip-install-8ny0s_zx/mysqlclient_45df0dcbeeaf46b3ae603aea98f6528d/setup_posix.py", line 31, in mysql_config raise OSError("{} not found".format(_mysql_config_path)) OSError: mysql_config not found mysql_config --version mariadb_config --version mysql_config --libs [end of output]
四、解决mysql_config not found的问题
文件没有办法访问(安装方式导致的),需要执行以下命令
sudo ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config
再次安装 mysqlclient 即可
pip install mysqlclient
来源地址:https://blog.csdn.net/qq_41522951/article/details/127912163