Mac 安装MySQL-python

一、yum安装

yum install -y MySQL-python.x86_64
复制代码

二、源码安装

1、首先需要安装mysql

2、下载 mysql-python

修改site.cfg文件

vim site.cfg
复制代码

修改以下内容

# mysql_config = /usr/local/bin/mysql_config
复制代码

改为

mysql_config = /usr/local/mysql/bin/mysql_config
复制代码

安装 MySQL-python

python setup.py install
复制代码

3、如遇到一下问题

root$ python setup.py install
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Traceback (most recent call last):
  File "setup.py", line 7, in 
    use_setuptools()
  File "/Users/software/python/MySQL-python/distribute_setup.py", line 145, in use_setuptools
    return _do_download(version, download_base, to_dir, download_delay)
  File "/Users/software/python/MySQL-python/distribute_setup.py", line 124, in _do_download
    to_dir, download_delay)
  File "/Users/software/python/MySQL-python/distribute_setup.py", line 194, in download_setuptools
    src = urlopen(url)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: SSL is required
复制代码

直接下载 distribute-0.6.28.tar.gz 放到目录下即可。

你可能感兴趣的:(Mac 安装MySQL-python)