Mac下安装MySQL-python模块时遇到的问题

一个关于在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.


大家觉得文章对你有些作用! 如果想赏钱,可以用微信扫描下面的二维码,感谢!
另外再次标注博客原地址  xiaorui.cc

发表评论

邮箱地址不会被公开。 必填项已用*标注