Command "python setup.py egg_info" failed with error code

解決pip install MySQL-python 報Command "python setup.py egg_info" failed with error code 問題解決方法

此方法 可能對你不可行,我也是嘗試了網(wǎng)上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 "<string>", line 1, in <module>
      File "/private/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Uuy2jA/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/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Uuy2jA/mysql-python/

1、執(zhí)行xcode-select --install
會彈出一個窗口,點(diǎn)擊安裝等待安裝完成

(py2env) DsHdeMacBook-Pro:bin dsh$ xcode-select --install
xcode-select: note: install requested for command line developer tools

2、執(zhí)行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 "<string>", line 1, in <module>
      File "/private/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Kssgvj/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/var/folders/0w/d8plqgs953q5ftqc98xbbptw0000gn/T/pip-build-Kssgvj/MySQL-python/

3、使用brew 安裝mysql

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

image.png

4、執(zhí)行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.

按照要求執(zhí)行brew unlink mysql-connector-c
5、再次執(zhí)行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、重新執(zhí)行 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、終于執(zhí)行成功,??

我使用的是mac 系統(tǒng), ubuntu系統(tǒng)應(yīng)該更這個步驟差不多,如果有問題可以留言討論?;蛘吣阌懈玫姆椒ǎ蛘吒玫慕忉屵@個問題的方式,可以告訴我,謝謝。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 在linux系統(tǒng)安裝MySQL-Python模塊一直在報這個錯,Google搜索了很久,看了一些不靠譜的解決方案浪...
    Neulana閱讀 8,226評論 2 1
  • 譯者按:原文寫于2011年末,雖然文中關(guān)于Python 3的一些說法可以說已經(jīng)不成立了,但是作為一篇面向從其他語言...
    EarlGrey閱讀 69,886評論 7 124
  • 這一點(diǎn)特別有必要反映在紀(jì)錄片里,就是一個違反常識的真實(shí)情況。最精銳的部隊(duì)在真實(shí)戰(zhàn)場中也只有25%的人會持續(xù)向敵人開...
    Atlas島閱讀 492評論 1 2
  • 一別十載故人飲,清濁陳淚濕衣襟。 好酒壺中乾坤大,推杯問盞解初心。
    abe4c0570901閱讀 169評論 0 2
  • 死亡是終點(diǎn)還是開始?無從知曉。本能地懼怕死亡,但終有一天我將獨(dú)自死去。那個行走在蒼茫大地間我的軀體,那一刻將會躺在...
    披著羽毛的豬閱讀 316評論 5 3

友情鏈接更多精彩內(nèi)容