mysqlclient安装报错【OSError: mysql_config not found】

  1. pip3 install mysqlclient安装时报错如下:
    Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
    Collecting mysqlclient
      Downloading http://mirrors.aliyun.com/pypi/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz (88 kB)
         |████████████████████████████████| 88 kB 2.2 MB/s 
        ERROR: Command errored out with exit status 1:
         command: /home/huzing2524/.virtualenvs/dap_data/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ri8xl694/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ri8xl694/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-xzfd5ms1
             cwd: /tmp/pip-install-ri8xl694/mysqlclient/
        Complete output (15 lines):
        /bin/sh: 1: mysql_config: not found
        /bin/sh: 1: mariadb_config: not found
        /bin/sh: 1: mysql_config: not found
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-ri8xl694/mysqlclient/setup.py", line 15, in <module>
            metadata, options = get_config()
          File "/tmp/pip-install-ri8xl694/mysqlclient/setup_posix.py", line 70, in get_config
            libs = mysql_config("libs")
          File "/tmp/pip-install-ri8xl694/mysqlclient/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
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    
  2. 在终端中安装:sudo apt install libmysqlclient-dev
  3. 重新安装mysqlclient即可:
    Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
    Collecting mysqlclient
      Downloading http://mirrors.aliyun.com/pypi/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz (88 kB)
         |████████████████████████████████| 88 kB 1.2 MB/s 
    Building wheels for collected packages: mysqlclient
      Building wheel for mysqlclient (setup.py) ... done
      Created wheel for mysqlclient: filename=mysqlclient-2.0.3-cp38-cp38-linux_x86_64.whl size=109287 sha256=c5aeb57d06169379a95a8eaf20a89d6aab062ccec217d310dbfe2bd88b9ce515
      Stored in directory: /home/huzing2524/.cache/pip/wheels/8e/ff/bf/c08c55e89d5891b74209ceeba17f7745cbe8ff04f2d787422e
    Successfully built mysqlclient
    Installing collected packages: mysqlclient
    Successfully installed mysqlclient-2.0.3
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值