【问题标题】:try to install MySQL-python on Mac but keeping get errors尝试在 Mac 上安装 MySQL-python 但不断出现错误
【发布时间】:2018-03-19 12:33:52
【问题描述】:

我在 Mac 10.13 上使用 python 2.7 我的 Mac 上已经有 MySQL,但是当我想安装 MySQL-python 时,总是报错。

我试过点子:

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'

真的很累……我尝试了很多我能找到的方法,但都没有奏效……

【问题讨论】:

    标签: python mysql macos pip mysql-python


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 2015-10-30
      • 2019-03-23
      • 1970-01-01
      • 2017-05-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多