'pip install MySQL-python' 失败 'IndexError'
'pip install MySQL-python' fails with 'IndexError'
我在 OSX El Capitan,使用 Python 2.7 (Anaconda)。启动命令 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/d2/gd004m2s35z5dlyz9mfn6sc40000gn/T/pip-build-FYvb_T/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
None 个有效(退出时出现同样的错误)。
pip install mysqlclient
easy_install MySQL-python
pip
是最新的。我基本上尝试遵循相关问题中的所有建议,但 none 成功了。感谢任何帮助,谢谢!
我在安装 pip install MySql-python
时遇到同样的错误。
然后,我使用以下命令安装了 libmysqlclient-dev
:
sudo apt install libmysqlclient-dev
安装后,我再次尝试,pip install MySql-python
它对我有用。
复制自this blog.
通过查找资料mysql-connector-c
可能得出brew安装的配置可能不正确的结论,打开/usr/local/bin/mysql_config
脚本修改部分内容:
#Create options
Libs = "-L$pkglibdir "
Libs = "$libs -l"
变为:
#Create options
Libs = "-L$pkglibdir"
Libs = "$libs -lmysqlclient -lssl -lcrypto"
保存
然后重新安装mysql-python:
pip install mysql-python
我遇到了同样的错误并按照以下说明解决了:
- brew 卸载 mysql-connector-c
- brew 安装mysql
- 调用 "mysql_config --libs" 并确认其输出包含正确的库选项:“-L/usr/local/Cellar/mysql/5.7.20/lib -lmysqlclient -lssl -lcrypto”
- export LDFLAGS=-L/usr/local/opt/openssl/lib && pip install mysqlclient
这解决了我的问题:
brew install mysql@5.7
brew link --force mysql@5.7
我在 OSX El Capitan,使用 Python 2.7 (Anaconda)。启动命令 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/d2/gd004m2s35z5dlyz9mfn6sc40000gn/T/pip-build-FYvb_T/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
None 个有效(退出时出现同样的错误)。
pip install mysqlclient
easy_install MySQL-python
pip
是最新的。我基本上尝试遵循相关问题中的所有建议,但 none 成功了。感谢任何帮助,谢谢!
我在安装 pip install MySql-python
时遇到同样的错误。
然后,我使用以下命令安装了 libmysqlclient-dev
:
sudo apt install libmysqlclient-dev
安装后,我再次尝试,pip install MySql-python
它对我有用。
复制自this blog.
通过查找资料mysql-connector-c
可能得出brew安装的配置可能不正确的结论,打开/usr/local/bin/mysql_config
脚本修改部分内容:
#Create options
Libs = "-L$pkglibdir "
Libs = "$libs -l"
变为:
#Create options
Libs = "-L$pkglibdir"
Libs = "$libs -lmysqlclient -lssl -lcrypto"
保存
然后重新安装mysql-python:
pip install mysql-python
我遇到了同样的错误并按照以下说明解决了:
- brew 卸载 mysql-connector-c
- brew 安装mysql
- 调用 "mysql_config --libs" 并确认其输出包含正确的库选项:“-L/usr/local/Cellar/mysql/5.7.20/lib -lmysqlclient -lssl -lcrypto”
- export LDFLAGS=-L/usr/local/opt/openssl/lib && pip install mysqlclient
这解决了我的问题:
brew install mysql@5.7
brew link --force mysql@5.7