我正在尝试让 Python 脚本在我通过 ssh 连接到的 linux 服务器上运行。该脚本使用 mysqldb。我有我需要的所有其他组件,但是当我尝试通过 setuptools 安装 mySQLdb 时:
python setup.py install
我收到以下与 mysql_config
命令相关的错误报告。
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/usr/lib/python2.5/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
有没有其他人遇到过这个错误,如果有,你是如何解决的/我该怎么做才能成功安装 mysqldb?
原文由 user904542 发布,翻译遵循 CC BY-SA 4.0 许可协议
mySQLdb 是 mysql 的 python 接口,但它不是 mysql 本身。显然 mySQLdb 需要命令’mysql_config’,所以你需要先安装它。
您能否通过从 shell 运行“mysql”来确认您是否安装了 mysql 本身?这应该会给您一个响应,而不是“mysql:找不到命令”。
您使用的是哪个 linux 发行版? Mysql 已为大多数 linux 发行版预先打包。例如,对于 debian/ubuntu,安装 mysql 就像
mysql-config 位于不同的包中,可以从以下位置安装(同样,假设 debian / ubuntu):
如果您使用的是 mariadb,则替换为 mysql,然后运行
参考: https ://github.com/JudgeGirl/Judge-sender/issues/4#issuecomment-186542797