alpine python3中使用mysql报错ModuleNotFoundError: No module named 'MySQLdb'

直接 pip3 install mysqlclient==2.0.1 报如下错误:

Collecting mysqlclient==2.0.1
  Downloading https://files.pythonhosted.org/packages/a5/e1/e5f2b231c05dc51d9d87fa5066f90d1405345c54b14b0b11a1c859020f21/mysqlclient-2.0.1.tar.gz (87kB)
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: not found
    /bin/sh: mariadb_config: not found
    /bin/sh: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-ht8sjvhp/mysqlclient/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-ht8sjvhp/mysqlclient/setup_posix.py", line 65, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-ht8sjvhp/mysqlclient/setup_posix.py", line 31, in mysql_config
        raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-ht8sjvhp/mysqlclient/
解决办法
echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories  && apk update  && apk add --no-cache mariadb-dev build-base
pip3 install mysqlclient==2.0.1 
posted @ 2020-09-21 17:08  巴黎斜塔  阅读(592)  评论(0编辑  收藏  举报