Mac下安装 mysqldb 出错

Last login: Sun Aug 10 21:07:51 on ttys001
SandymatoMacBook-Pro:MySQL-python-1.2.4b4 sandy$ sudo python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-intel-2.7/MySQLdb
running build_ext
Traceback (most recent call last):
  File "setup.py", line 21, in <module>
    setup(**metadata)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run
    self.run_command(cmd_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "build/bdist.macosx-10.6-intel/egg/setuptools/command/build_ext.py", line 46, in run
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build_ext.py", line 307, in run
    customize_compiler(self.compiler)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/sysconfig.py", line 170, in customize_compiler
    _osx_support.customize_compiler(_config_vars)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_osx_support.py", line 418, in customize_compiler
    _find_appropriate_compiler(_config_vars)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_osx_support.py", line 191, in _find_appropriate_compiler
    "Cannot locate working compiler")
SystemError: Cannot locate working compiler
SandymatoMacBook-Pro:MySQL-python-1.2.4b4 sandy$ 

安装mysqldb:

MySQL for Python http://sourceforge.net/projects/mysql-python/
tar zxvf MySQL-python

cd MySQL-python-1.2.4b4

python setup.py install 报了以上错误

 

原因:电脑没有安装gcc

gcc 是c 语言的编译器,python-mysql 有一部分代码实现是c 做的,要用gcc 编译

 

安装gcc :

https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg 

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。