原因:pip命令安装库时默认从国外网站下载,网络不通畅时就会下载失败。
解决办法:
1.pip安装库时同时指定国内镜像源(临时生效,下次打开cmd就失效了)。
如:pip install pymysql -i https://pypi.tuna.tsinghua.edu.cn/simple
2.修改本地配置(永久生效)。
在cmd输入以下命令:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes