尝试在Python 3.6.0上使用pip3安装mysqlclient
$ pip3 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 54, in get_config
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 54, in <listcomp>
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/setup_posix.py", line 12, 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/3k/08g3yx_12kg99kyfs989md600000gn/T/pip-build-1qv_89jc/mysqlclient/
已经有了
brew install mysql-connector-c
但还是犯了这个错误
在进行了大量的故障排除之后,我发现
brew install mysql-connector-c
根本不起作用。问题源于系统无法识别已安装的
mysql_config
(这就是mysql-connector-c
的本质)。当Python试图遵循符号链接时,Homebrew在其/Cellar/
中安装mysql-connector-c
并创建指向/usr/local/bin/
目录的符号链接的方法(open for argument)似乎导致了问题。为解决此问题,我执行了以下操作:
brew uninstall mysql-connector-c
.dmg
,这里不需要复杂。。。which mysql_config
/usr/local/bin/mysql/bin/mysql_config
激活
virtualenv
(如果适用)pip install mysqlclient
可能还有其他方法可以继续使用自制,但这是我找到的最直接的解决方案。
注意,
mysqlclient
GitHub README.md还声明需要Python3的C-developer头。我假设mysql-connector-c
包含这些;但是,如果遇到更多问题,您也可以安装Xcode开发人员CI工具,以获得良好的效果。xcode-select --install
它们包括C编译器和其他来自苹果的开发工具。阅读更多here。
我解决了首先安装libmysqlclient dev的问题:
希望对你有用。
这对我有效:
brew install mysql-connector-c
编辑
mysql_config
(找到它:which mysql_config
)在mysql配置中更正此错误:
应该是:
brew info openssl
pip3 install mysqlclient
相关问题 更多 >
编程相关推荐