解決pip install MySQL-python 報(bào)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
會(huì)彈出一個(gè)窗口漆弄,點(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
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)該更這個(gè)步驟差不多寸士,如果有問題可以留言討論〔晡裕或者你有更好的方法弱卡,或者更好的解釋這個(gè)問題的方式,可以告訴我住册,謝謝婶博。