我在Mac 10.13上使用python 2.7 我已经在我的Mac上安装了MySQL,但是当我想安装MySQL-python时,不断出现错误。
我试过pip:
sudo pip install mysql-python
但得到了:
Collecting mysql-python
Downloading MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 1.9MB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-AhyoBa/mysql-python/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libraries = [ dequote(i[2:]) for i in libs if i.startswith(compiler_flag("l")) ]
File "setup_posix.py", line 8, in dequote
if s[0] in "\"'" and s[0] == s[-1]:
IndexError: string index out of range
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-AhyoBa/mysql-python/
然后我尝试将文件直接移到'site-package',并运行:
python /Users/dandizhao/Downloads/MySQL-python-1.2.5/setup.py install
但仍然有:
Traceback (most recent call last):
File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup.py", line 17, in <module>
metadata, options = get_config()
File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup_posix.py", line 32, in get_config
metadata, options = get_metadata_and_options()
File "/Users/dandizhao/Downloads/MySQL-python-1.2.5/setup_common.py", line 12, in get_metadata_and_options
metadata = dict(config.items('metadata'))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 642, in items
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'metadata'
真的很累......我尝试了很多我能找到的方法,但没有一种方法有效......
答案 0 :(得分:4)
我继续this link here,这似乎是MySQL和MacOS的常见问题。
在终端中尝试使用这些命令
$ brew uninstall mysql
$ brew install mysql-connector-c
$ brew unlink mysql-connector-c
$ brew install mysql
$ pip install mysql-python