pip3 安装mysqlclient
显示如下错误,
Collecting mysqlclient
Using cached mysqlclient-1.3.12.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/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/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/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/setup_posix.py", line 54, in <listcomp>
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/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/58/m4f65nln59dbf0sf6x70l5zw0000gn/T/pip-build-ruton_ve/mysqlclient/
关注了一些帖子并安装了
brew install mysql-connector-c
但仍然面临这个问题。
对于其他解决方案尝试了以下解决方案,
https://stackoverflow.com/a/44338332/4107739
但是找不到/usr/local/bin/mysql/bin/mysql_config
我在 MacOS 上运行,对于 Mysql,我安装了 XAMPP。
请您参考如下方法:
对于 python3 + mac 上的 mysql。这对我有用:
brew install mysql-connector-c
- 编辑 mysql_config(找到它:
which mysql_config
)
在 mysql_config 中更改以下内容:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
收件人:
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
brew info openssl
最后
pip3 install mysqlclient