码迷,mamicode.com
首页 > 数据库 > 详细

mac下python3.6安装mysqlclient报错mysql_config: command

时间:2019-07-21 13:46:17      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:data   github   提示   and   安装mysql   private   方式   报错   set   

用mac在python3.6的环境下学习django,按照官网的步骤,却无法安装mysqlclient。报错mysql_config: command not found。

命令如下:

$ pip3 install mysqlclient

pip3是因为有两个python版本,给python3.6对应的pip起了个别名。不然提示找不到。
报错如下:

Collecting mysqlclient
Using cached mysqlclient-1.3.12.tar.gz

Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/folders/ww/hnzjh2z517d72m15ybyhwkbw0000gn/T/pip-build-mvq09hkr/mysqlclient/setup.py", line 17, in <module>
    metadata, options = get_config()
  File "/private/var/folders/ww/hnzjh2z517d72m15ybyhwkbw0000gn/T/pip-build-mvq09hkr/mysqlclient/setup_posix.py", line 44, in get_config
    libs = mysql_config("libs_r")
  File "/private/var/folders/ww/hnzjh2z517d72m15ybyhwkbw0000gn/T/pip-build-mvq09hkr/mysqlclient/setup_posix.py", line 26, 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 /private/var/folders/ww/hnzjh2z517d72m15ybyhwkbw0000gn/T/pip-build-mvq09hkr/mysqlclient/

解决方法:

1、在~/.bash_profile中加入mysql.的路径

 $ cat ~/.bash_profile

set PATH /Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Wireshark.app/Contents/MacOS:/usr/local/mysql/bin
export PATH

2、安装mysql-connector-c
brew install mysql-connector-c

如果电脑没有安装brew,按照以下方式安装brew,再安装mysql-connector-c:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

3、再次安装
$ pip3 install mysqlclient

mac下python3.6安装mysqlclient报错mysql_config: command

标签:data   github   提示   and   安装mysql   private   方式   报错   set   

原文地址:https://blog.51cto.com/qiangsh/2422115

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!