美文网首页数据库
Linux 上安装 mysqlclient

Linux 上安装 mysqlclient

作者: handsomeFu | 来源:发表于2018-10-06 19:31 被阅读0次

    Linux 下安装 mysqlclient,如果是选择直接安装的话,一般会报如下错误,

    (djenv) handsome@fzq:~$ pip install mysqlclient -i https://pypi.doubanio.com/simple/
    Looking in indexes: https://pypi.doubanio.com/simple/
    Collecting mysqlclient
      Downloading https://pypi.doubanio.com/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz (90kB)
        100% |████████████████████████████████| 92kB 2.1MB/s 
        Complete output from command python setup.py egg_info:
        /bin/sh: 1: mysql_config: not found
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-y16_5477/mysqlclient/setup.py", line 18, in <module>
            metadata, options = get_config()
          File "/tmp/pip-install-y16_5477/mysqlclient/setup_posix.py", line 53, in get_config
            libs = mysql_config("libs_r")
          File "/tmp/pip-install-y16_5477/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-install-y16_5477/mysqlclient/
    

    解答方案, 一般来说安装一个依赖即可

    (djenv) handsome@fzq:~$ sudo apt install libmysqlclient-dev
    

    安装完依赖之后,再次执行pip install mysqlclient -i https://pypi.doubanio.com/simple/ 即可成功安装

    相关文章

      网友评论

        本文标题:Linux 上安装 mysqlclient

        本文链接:https://www.haomeiwen.com/subject/yqnhaftx.html