gpt4 book ai didi

python - 尝试在 Mac 上安装 MySQL-python 但一直出现错误

转载 作者:太空宇宙 更新时间:2023-11-03 10:36:56 24 4
gpt4 key购买 nike

我在 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'

真的很累...我尝试了很多我能找到的方法,但没有一个有效...

最佳答案

我继续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

关于python - 尝试在 Mac 上安装 MySQL-python 但一直出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46627142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com