一个关于在mac下的python MySQLdb安装笔记,在mac下安装一些python 模块的方法有些形式上的差异. 比如python MySQLdb是需要装mysql-devel.  我Mac的Mysql server是直接dmg安装的。 所有不需要考虑太多的东西.  

文章写的不是很严谨,欢迎来喷,另外该文后续有更新的,请到原文地址查看更新。

http://xiaorui.cc


首先需要把你的mysql/bin下的命令连接放到已存在的PATH里面. 


sudo ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

#   以前brew安装过Mysql server, 之后安装MySQL-python很是顺溜. 


[ruifengyun@devops ~ ]$ sudo pip install MySQL-python
The directory ‘/Users/ruifengyun/Library/Logs/pip’ or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
The directory ‘/Users/ruifengyun/Library/Caches/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
You are using pip version 6.0.6, however version 8.0.0 is available.
You should consider upgrading via the ‘pip install –upgrade pip’ command.
The directory ‘/Users/ruifengyun/Library/Caches/pip/http’ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
Collecting MySQL-python
  Downloading MySQL-python-1.2.5.zip (108kB)
    100% |################################| 110kB 201kB/s
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File “<string>”, line 20, in <module>
      File “/tmp/pip-build-pRKntn/MySQL-python/setup.py”, line 17, in <module>
        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
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found

    Traceback (most recent call last):

      File “<string>”, line 20, in <module>

      File “/tmp/pip-build-pRKntn/MySQL-python/setup.py”, line 17, in <module>

        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 /tmp/pip-build-pRKntn/MySQL-python
[ruifengyun@devops ~ ]$

遇到遇到  sh: mysql_config: command not found的问题,需要你安装下 mysql-connector-c .

[ruifengyun@devops ~ ]$ sudo brew install mysql-connector-c
==> Downloading http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.3-src.tar.gz
######################################################################## 100.0%
==> Patching
==> cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/homebrew/Cellar/mysql-connector-c/6.1.3 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev
==> make
==> make install
 /usr/local/homebrew/Cellar/mysql-connector-c/6.1.3: 70 files, 16M, built in 82 seconds

END.



对Python及运维开发感兴趣的朋友可以加QQ群 : 478476595 !!!
{ 2000人qq大群内有各厂大牛,常组织线上分享及沙龙,对高性能及分布式场景感兴趣同学欢迎加入该QQ群 }

另外如果大家觉得文章对你有些作用!   帮忙点击广告. 一来能刺激我写博客的欲望,二来好维护云主机的费用.
如果想赏钱,可以用微信扫描下面的二维码. 另外再次标注博客原地址  xiaorui.cc  ……   感谢!
暂无相关产品

发表评论