Python安装三方库包出现timeout的解决方法

参考了几种网上的办法,下述办法最便捷且亲测有效。

1.新建一个.py文件

新建pippeizhi.py

import os
 
ini="""[global]
index-url = https://pypi.doubanio.com/simple/
[install]
trusted-host=pypi.doubanio.com
"""
pippath=os.environ["USERPROFILE"]+"\\pip\\"
 
if not os.path.exists(pippath):
    os.mkdir(pippath)
 
with open(pippath+"pip.ini","w+") as f:
    f.write(ini)
print('OK')

这里用了 douban 的源。

2.cmd运行python 文件路径 pippeizhi.py

3.cmd中输入pip install ***就可以安装自己想要的库。

代码出处:https://blog.csdn.net/qq_36659201/article/details/81534280

博主:从嘉嘉

猜你喜欢

转载自www.cnblogs.com/hhf821244793/p/11979558.html