安装命令
pip3 install mysqlclient
报错信息1
Collecting mysqlclient
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x1106f68d0>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/mysqlclient/
Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x1106f6da0>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/mysqlclient/
原因
网络不通
用豆瓣源
lee$ pip install -i https://pypi.douban.com/simple mysqlclient
报错信息2
Command "python setup.py egg_
info" failed with error code 1 in
/private/var/folders/mm/
wv2k__sx7yj9hyk61bf5j428
0000gn/T/pip-build-6qfg_m7
h/mysqlclient/
解决办法
# 安装mysql驱动,你的电脑很可能已经安装过了
brew install mysql-connector-c
cd /usr/local/Cellar/mysql-connector-c/6.1.11/bin/mysql_config
# 修改前先备份
cp mysql_config mysql_config.backup
# 使用vi修改配置文件
sudo vi mysql_config
# 114 gg跳转到 114行
将
> # Create options
> libs="-L$pkglibdir"
> libs="$libs -l "
替换为
> # Create options
> libs="-L$pkglibdir"
> libs="$libs -lmysqlclient -lssl -lcrypto"
[图片上传中...(image.png-b31ee3-1516583989648-0)]
然后保存即可。
# 然后重新运行mysqlclient安装命令,之后一切顺利,大功告成
pip install mysqlclient