mac mysqlclient python setup.py egg_info IndexError: string index out of range

我是从 这里 看到的解决办法

感谢 Joker先生 先生

虽然他解决的是mySQL-pytho,但同样能解决我在安装mysqlclient是的问题


解决pip install MySQL-python 报Command "python setup.py egg_info" failed with error code 问题解决方法

此方法 可能对你不可行,我也是尝试了网上N种方法才解决好的,至于是哪种方法解决的我也不清楚

Collecting mysql-python

Using cached MySQL-python-1.2.5.zip

Complete output from command python setup.py egg_info:

Traceback (most recent call last):

File "", line 1, in

File "/private/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Uuy2jA/mysql-python/setup.py", line 17, in

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/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Uuy2jA/mysql-python/





1、执行xcode-select --install

会弹出一个窗口,点击安装等待安装完成

(py2env) DsHdeMacBook-Pro:bin dsh$ xcode-select --install

xcode-select: note: install requested for command line developer tools




2、执行pip install MySQL-python

Collecting MySQL-python

Using cached MySQL-python-1.2.5.zip

Complete output from command python setup.py egg_info:

Traceback (most recent call last):

File "", line 1, in

File "/private/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Kssgvj/MySQL-python/setup.py", line 17, in

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/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Kssgvj/MySQL-python/





3、使用brew 安装mysql

https://brew.sh/index_zh-cn.html





4、执行brew install mysql

Error: Cannot install mysql because conflicting formulae are installed.

mysql-connector-c: because both install MySQL client libraries

Please `brew unlink mysql-connector-c` before continuing.

Unlinking removes a formula's symlinks from /usr/local. You can

link the formula again after the install finishes. You can --force this

install, but the build may fail or cause obscure side-effects in the

resulting software.

按照要求执行brew unlink mysql-connector-c






5、再次执行brew install mysql

==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.19.sierra.bottle.

Already downloaded: /Users/dsh/Library/Caches/Homebrew/mysql-5.7.19.sierra.bottle.tar.gz

==> Pouring mysql-5.7.19.sierra.bottle.tar.gz

==> Caveats

We've installed your MySQL database without a root password. To secure it run:

mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:

mysql -uroot

To have launchd start mysql now and restart at login:

brew services start mysql

Or, if you don't want/need a background service you can just run:

mysql.server start

==> Summary

🍺  /usr/local/Cellar/mysql/5.7.19: 322 files, 233MB





6、重新执行 pip install MySQL-python

Collecting MySQL-python

Using cached MySQL-python-1.2.5.zip

Building wheels for collected packages: MySQL-python

Running setup.py bdist_wheel for MySQL-python ... done

Stored in directory: /Users/dsh/Library/Caches/pip/wheels/38/a3/89/ec87e092cfb38450fc91a62562055231deb0049a029054dc62

Successfully built MySQL-python

Installing collected packages: MySQL-python

Successfully installed MySQL-python-1.2.5

7、终于执行成功,😄

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容