我目前正在使用Mac OS X 10.12。我正在尝试安装MySQLdb但是仍然遇到这些错误。
当我运行sudo pip install MySQLdb时,错误信息是:
Collecting MySQL-python
Downloading MySQL-python-1.2.5.zip (108kB)
100% |████████████████████████████████| 112kB 233kB/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-m1bhp0l0/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/tmp/pip-build-m1bhp0l0/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-m1bhp0l0/MySQL-python/
然后我尝试下载MySQL-python-1.2.4b4,并使用它直接运行setup.py.Then我收到此错误:
Traceback (most recent call last):
File "/Users/phil/Downloads/MySQL-python-1.2.4b4 2/setup.py", line 18, in <module>
metadata, options = get_config()
File "/Users/phil/Downloads/MySQL-python-1.2.4b4 2/setup_posix.py", line 32, in get_config
metadata, options = get_metadata_and_options()
File "/Users/phil/Downloads/MySQL-python-1.2.4b4 2/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'
尝试了很多解决方案。还有很多错误。 Plz在这里帮忙。
答案 0 :(得分:3)
问题是MySQL-python包没有currently support Python 3。
你可以使用另一个像mysqlclient这样的mysql包,它是MySQL-python的一个分支,支持Python 3,对我来说效果很好:
sudo pip install mysqlclient
或者如果您仍然需要使用MySQL-python,您可以尝试在Python 2.7中安装它并将其用于开发:
sudo pip2 install MySQL-python
希望这会有所帮助。