技术学习分享_CKX技术 技术资讯 mysqlclient 安装问题

mysqlclient 安装问题

广告位

OSError: mysql_config not found

ERROR: Command errored out with exit status 1:
command: /Users/kai/Desktop/workspace/Projects/work_hour/work_hours_system_backend/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6p/_zlkj9s510l53q7_7cpq0_br0000gn/T/pip-install-cmdtjn9e/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/6p/_zlkj9s510l53q7_7cpq0_br0000gn/T/pip-install-cmdtjn9e/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /private/var/folders/6p/_zlkj9s510l53q7_7cpq0_br0000gn/T/pip-install-cmdtjn9e/mysqlclient/
Complete output (15 lines):
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found
mysql_config --version
mariadb_config --version
mysql_config --libs
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/6p/_zlkj9s510l53q7_7cpq0_br0000gn/T/pip-install-cmdtjn9e/mysqlclient/setup.py", line 15, in <module>
metadata, options = get_config()
File "/private/var/folders/6p/_zlkj9s510l53q7_7cpq0_br0000gn/T/pip-install-cmdtjn9e/mysqlclient/setup_posix.py", line 70, in get_config
libs = mysql_config("libs")
File "/private/var/folders/6p/_zlkj9s510l53q7_7cpq0_br0000gn/T/pip-install-cmdtjn9e/mysqlclient/setup_posix.py", line 31, in mysql_config
raise OSError("{} not found".format(_mysql_config_path))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方式

个人感觉,安装一个驱动不需要安装服务端。“有这么干的”

mac

[官方链接](​​MySQL 客户端 ·皮皮 (pypi.org)​​)

可以安装客户端

# Assume you are activating Python 3 venv
$ brew install mysql
$ pip install mysqlclient

本地 docker 不需安装 mysql 客户端

# 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

总结

其实,报错信息中提示了。安装mysqlclient,需要获取一些本地的 mysql 配置文件。没有就会报错。

/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found

Linux是程序员必备的技能,碎片时间利用起来,买本纸质书籍。研究一下,受用终生。

linux、window需要时更新

本文来自网络,不代表技术学习分享_CKX技术立场,转载请注明出处。

作者: CKX技术

上一篇
下一篇
广告位

发表回复

返回顶部