有三种常用方式:
①永久设置:

vim /etc/profile:
export http_proxy='http://代理服务器IP:端口号'
export https_proxy='http://代理服务器IP:端口号'
source /etc/profile

②临时设置(重连后失效):
也可以直接运行export http_proxy='http://代理服务器IP:端口号
export https_proxy='http://代理服务器IP:端口号'

注意:设置之后可能使用ping时还是无法连接外网,但是pip时可以的,因为ping的协议不一样不能使用这个代理

③单次设置:
直接在pip时设置代理也是可以的:
pip install -r requirements.txt --proxy=代理服务器IP:端口号

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code