解决pip安装时被墙或SSLError
经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的烦恼。
国内源:
新版ubuntu要求使用https源,要注意。
清华:[https://pypi.tuna.tsinghua.edu.cn/simple]{.ul}
阿里云:[http://mirrors.aliyun.com/pypi/simple/]{.ul}
中国科技大学 [https://pypi.mirrors.ustc.edu.cn/simple/]{.ul}
华中理工大学:[http://pypi.hustunique.com/]{.ul}
山东理工大学:[http://pypi.sdutlinux.org/]{.ul}
豆瓣:[http://pypi.douban.com/simple/]{.ul}
临时使用:
可以在使用pip的时候加参数-i [https://pypi.tuna.tsinghua.edu.cn/simple]{.ul}
例如:pip install
-i [https://pypi.tuna.tsinghua.edu.cn/simple]{.ul} pyspider,这样就会从清华这边的镜像去安装pyspider库。
永久修改,一劳永逸:
Linux和Mac下,修改 ~/.pip/pip.conf
(没有就创建一个文件夹及文件。文件夹要加”.”,表示是隐藏文件夹)
Window下的路径是C:user(或者用户)电脑的用户名pippip.ini
内容如下:
[global]
index-url
= [http://mirrors.aliyun.com/pypi/simple/]{.ul}
[install]
trusted-host=mirrors.aliyun.com
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!