相关信息
如果你的代理都是 HTTP 的,并且是自己使用的,那么 HTTP 代理是完全可以满足需求的。以下是通过终端输入的方式,分别为 Python (pip) 和 Node.js (npm) 设置全局 HTTP 代理的具体步骤:
在终端中执行以下命令:
bashpip config set global.proxy http://username:password@proxy_address:port
如果代理不需要用户名和密码认证,直接写代理地址:
bashpip config set global.proxy http://proxy_address:port
bashpip config set global.proxy http://192.168.1.1:8080
查看配置是否生效:
bashpip config list
如果需要删除全局代理:
bashpip config unset global.proxy
在终端中执行以下命令:
bashnpm config set proxy http://username:password@proxy_address:port
如果代理不需要用户名和密码认证:
bashnpm config set proxy http://proxy_address:port
即使代理是 HTTP 的,建议同时为 HTTPS 设置,方便访问 HTTPS 网站:
bashnpm config set https-proxy http://username:password@proxy_address:port
bashnpm config set proxy http://192.168.1.1:8080
npm config set https-proxy http://192.168.1.1:8080
bashnpm config get proxy npm config get https-proxy
如果需要移除代理设置:
bashnpm config delete proxy npm config delete https-proxy
如果你只有 HTTP 代理,直接在 pip 和 npm 中使用 http://proxy_address:port
即可,它们会自动适配 HTTP 和 HTTPS 请求。
两者的命令对比总结:
pip config set global.proxy
。npm config set proxy
和 npm config set https-proxy
。希望这对你有帮助! 😊
本文作者:钰
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!