pip3 install mysqlclient 报错 “/bin/sh: 1: mysql_config: not found”的解决方法

2022-08-05 20:38:51 浏览数 (1)

报错信息

代码语言:javascript复制
[root@localhost hc_BgpServer]# pip3 install mysqlclient 
Collecting mysqlclient
  Downloading https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz (85kB)
    100% |████████████████████████████████| 92kB 10kB/s 
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: 未找到命令
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-p7rj4zl1/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-p7rj4zl1/mysqlclient/setup_posix.py", line 51, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-p7rj4zl1/mysqlclient/setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    OSError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-p7rj4zl1/mysqlclient/
  1. centos
代码语言:javascript复制
yum -y install mysql-devel
pip3 install mysqlclient

成功 2. ubuntu 执行

代码语言:javascript复制
执行 sudo apt-get install libmysqlclient-dev,
然后执行 pip3 install mysqlclient

成功。

  1. debian
代码语言:javascript复制
apt install libmariadbd18 -y

0 人点赞