美文网首页我爱编程
mac 装 mysql-python的坑

mac 装 mysql-python的坑

作者: 死也要学会django | 来源:发表于2018-02-08 10:59 被阅读46次

    作为小白,折腾了很久,查了很多资料,才把这儿坑给填了

    一般来说,安装mysql-python 驱动,只需要

    pip install mysql-python

    可是会报错。

     Using cached MySQL-python-1.2.5.zip    

    Complete output from command python setup.py
    egg_info:     sh: mysql_config: command not found    
    Traceback (most recent call last):      
     File "", line 1, in       File "/private/var/folders/5r/z0n8d2bx1gng1bcbptynj6wr0000gn/T/pip-build-af7hi2/mysql-python/setup.py", line 17, in         metadata, options = get_config()       File "setup_posix.py", line 43, in get_config         libs = mysql_config("libs_r")       File "setup_posix.py", line 25, in mysql_config         raise EnvironmentError("%s not found" % (mysql_config.path,))     EnvironmentError: mysql_config not found          ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/5r/z0n8d2bx1gng1bcbptynj6wr0000gn/T/pip-build-af7hi2/mysql-python/

    解决方法

    1 官网现在 mysql-python

    https://pypi.python.org/pypi/MySQL-python/1.2.5

    2 解压,并在文本编辑软件中,修改解压文件夹中的site.cfg

    3 找到如下的句子

    # The path to mysql_config.
    # Only use this if mysql_config is not on your PATH, or you have some weird
    # setup that requires it.
    # mysql_config = /usr/local/bin/mysql_config

    4 把最后一句的备注符号去掉,并替换为 mysql_config = /usr/local/mysql/bin/mysql_config

    修改后的格式为

    # The path to mysql_config. 
    # Only use this if mysql_config is not on your PATH, or you have some weird 
    # setup that requires it. 
    mysql_config = /usr/local/mysql/bin/mysql_config

    5 用terminal 进入 加压后的文件, 并运行 $ python setup.py install

    $ python setup.py install

    相关文章

      网友评论

        本文标题:mac 装 mysql-python的坑

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