Mac 安裝MySQL-python

CoderSunYu發表於2018-10-18

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 <module>
    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 放到目錄下即可。

相關文章