macOS 中安装 mysqlclient

macOS 中安装 mysqlclient

环境

  • python3.7
  • macOS 10.15.2

报错信息

Collecting flask_mysqldb
  Downloading https://pypi.doubanio.com/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz (2.1 kB)
Requirement already satisfied: Flask>=0.10 in /Users/wollens/.local/share/virtualenvs/flask-mini-program-xHpomphc/lib/python3.7/site-packages (from flask_mysqldb) (1.1.1)
Collecting mysqlclient
  Downloading https://pypi.doubanio.com/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz (85 kB)
     |████████████████████████████████| 85 kB 9.1 MB/s
    ERROR: Command errored out with exit status 1:
     command: /Users/wollens/.local/share/virtualenvs/flask-mini-program-xHpomphc/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hm/bxywlv396f345p3vxffzwb6h0000gn/T/pip-install-kv0lyhl8/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/hm/bxywlv396f345p3vxffzwb6h0000gn/T/pip-install-kv0lyhl8/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 /private/var/folders/hm/bxywlv396f345p3vxffzwb6h0000gn/T/pip-install-kv0lyhl8/mysqlclient/pip-egg-info
         cwd: /private/var/folders/hm/bxywlv396f345p3vxffzwb6h0000gn/T/pip-install-kv0lyhl8/mysqlclient/
    Complete output (12 lines):
    /bin/sh: mysql_config: command not found
    /bin/sh: mariadb_config: command not found
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "", line 1, in 
      File "/private/var/folders/hm/bxywlv396f345p3vxffzwb6h0000gn/T/pip-install-kv0lyhl8/mysqlclient/setup.py", line 16, in 
        metadata, options = get_config()
      File "/private/var/folders/hm/bxywlv396f345p3vxffzwb6h0000gn/T/pip-install-kv0lyhl8/mysqlclient/setup_posix.py", line 61, in get_config
        libs = mysql_config("libs")
      File "/private/var/folders/hm/bxywlv396f345p3vxffzwb6h0000gn/T/pip-install-kv0lyhl8/mysqlclient/setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    OSError: mysql_config not found
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方案

brew install mysql-client
pip3 install mysqlclient

注意⚠️:如果以上操作还是不能解决你的问题请参照:https://www.jianshu.com/p/80f3f07f834c

你可能感兴趣的:(日常填坑)