[英]Cannot pip3 install mysqlclient
pip3 install mysqlclient pip3安装mysqlclient
shows the following error, 显示以下错误,
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/
followed some posts and installed 关注一些帖子并安装完毕
brew install mysql-connector-c
But Still facing the issue. 但仍然面临着这个问题。
For other solution tried the following solution, 对于其他解决方案尝试以下解决方案
https://stackoverflow.com/a/44338332/4107739 https://stackoverflow.com/a/44338332/4107739
but couldn't find /usr/local/bin/mysql/bin/mysql_config 但找不到/ usr / local / bin / mysql / bin / mysql_config
I'm running on MacOS, for Mysql I have XAMPP installed. 我在MacOS上运行,对于Mysql,我安装了XAMPP。
For python3 + mysql on mac. 对于mac上的python3 + mysql。 This worked for me: 这对我有用:
brew install mysql-connector-c
which mysql_config
) 编辑mysql_config(找到它: which mysql_config
) Change the following in mysql_config: 在mysql_config中更改以下内容:
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
To: 至:
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
brew info openssl
and finally pip3 install mysqlclient
最后pip3 install mysqlclient
in XAMPP, the mysql_config would be somewhere in the below path. 在XAMPP中,mysql_config将位于以下路径中的某个位置。 (based where you installed) (根据你安装的地方)
/Applications/XAMPP/xamppfiles/bin/mysql_config
Update the $PATH to include bin path 更新$ PATH以包含bin路径
export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin/
Run mysql_config, --libs
and --libs_r
should have -lmysqlclient -lssl -lcrypto
, 运行mysql_config, - --libs
和--libs_r
应该有-lmysqlclient -lssl -lcrypto
,
<XAMPP_PATH>mysql_config | grep libs
--libs [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqlclient -lssl -lcrypto]
--libmysqld-libs [-L/usr/local/Cellar/mysql/5.7.21/lib -lmysqld -lssl -lcrypto]
if not, update the mysql_config to following values. 如果没有,请将mysql_config更新为以下值。
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
then run 然后运行
pip3 install mysqlclient
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.