报错记录
Looking in indexes: https://pypi.douban.com/simple/
Collecting mysqlclient
Using cached https://pypi.doubanio.com/packages/50/5f/eac919b88b9df39bbe4a855f136d58f80d191cfea34a3dcf96bf5d8ace0a/mysqlclient-2.1.1.tar.gz (88 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [18 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 "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/jn/2ypp3lsn0msc_zx6lljzd6qr0000gn/T/pip-install-68skmfpn/mysqlclient_c52b6bfd1d63422185f0b76b9fa09f9d/setup.py", line 15, in <module>
metadata, options = get_config()
^^^^^^^^^^^^
File "/private/var/folders/jn/2ypp3lsn0msc_zx6lljzd6qr0000gn/T/pip-install-68skmfpn/mysqlclient_c52b6bfd1d63422185f0b76b9fa09f9d/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/jn/2ypp3lsn0msc_zx6lljzd6qr0000gn/T/pip-install-68skmfpn/mysqlclient_c52b6bfd1d63422185f0b76b9fa09f9d/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]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed× Encountered error while generating package metadata.
╰─> See above for output.note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
根据下方这两条报错信息去解决:
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not
无意中看到我现在的mysql_config文件在/usr/local/mysql-8.0.32-macos13-x86_64/bin目录下。
解决办法:
目前
电脑版本:MacOS Ventura 13.0
python 3.11.3
MySQL:8.0.32
配置一下环境变量(我是小白,不太懂,最后安装成功了就好了)
zsh Shell修改配置文件(应该是叫配置文件吧)
sudo vim ~/.zprofile
——————
大佬的文章很有用
https://www.jianshu.com/p/273f0bc0f9d7
https://www.cnblogs.com/menglx/p/12858787.html
下方截图,红框内是我新配置的路经
ESC退出,shift键+Z Z保存并退出文件。
使环境变量生效.↓↓↓↓↓↓↓
source ~/.zprofile
查看变量是否生效
echo $PATH
使用pip 安装 mysqlclient ,安装成功