解决centos7安装mysqlclient的错误

公司买了一台测试服务器,需要把测试服务器搭一下,小记搭建过程遇到的小问题

基本版本信息
  • centos7.6
  • python3.7
  • django2.2

安装mysqlclient需要如下错误:

# pip3 install mysqlclient
Collecting mysqlclient
  Downloading http://mirrors.aliyun.com/pypi/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz (90kB)
    100% |████████████████████████████████| 92kB 18.7MB/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-build-tv34qz2u/mysqlclient/setup.py", line 18, in <module>
        metadata, options = get_config()
      File "/tmp/pip-build-tv34qz2u/mysqlclient/setup_posix.py", line 53, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-build-tv34qz2u/mysqlclient/setup_posix.py", line 28, 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-build-tv34qz2u/mysqlclient/
--------------------- 

错误信息可以看出来, mysql_config这个依赖包出现了问题。
解决问题:
添加软连接

ln -s /usr/local/mysql/bin/mysql_config /usr/local/bin/mysql_config

添加软连接以后还是不行的话呢,再做如下操作:

# 先安装mysql-devel,后安装mysqlclient
yum install mysql-devel
pip3 install mysqlclient

完美解决问题

[root@iZwz98au0xz9ipxecv5nayZ web]# pip3 install mysqlclient            
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting mysqlclient
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz (85kB)
     |████████████████████████████████| 92kB 11.3MB/s
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... done
  Stored in directory: /root/.cache/pip/wheels/b0/3e/e7/a7697d41d7f04f677196576c9a4edb6e749788fd8a4bd6e0ce
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.2.post1

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值