转载自这位老哥:
https://blog.csdn.net/liu940129953/article/details/107358559
//首先,设置默认代理,也可以理解为清除代理
git config --global --unset http.proxy
git config --global --unset https.proxy
//设置代理
git config --global http.proxy "socks5://127.0.0.1:7890"
git config --global https.proxy "socks5://127.0.0.1:7890"
// 有公司的填写你们公司的代理
git config --global http.proxy http://proxy.xxx.com:8080
git config --global https.proxy https://proxy.xxx.com:8080
// v2rayN 的端口默认为 10808
git config --global http.proxy "socks5://x.x.139.7:10808"
git config --global https.proxy "socks5://x.x.139.7:10808"
端口要自己改
参考本文的单次设置:
https://zhuanlan.zhihu.com/p/371953325
pip install -r requirements.txt --proxy="socks5://127.0.0.1:7890"
ERROR: Could not install packages due to an OSError: Missing dependencies for SOCKS support.
WARNING: There was an error checking the latest version of pip.
参考这里:
1. https://stackoverflow.com/questions/38794015/pythons-requests-missing-dependencies-for-socks-support-when-using-socks5-fro
2. https://blog.csdn.net/whatday/article/details/109287343
$ pip install pysocks
即可
如果直接安装出现:
> pip install -r requirements.txt --proxy="socks5://127.0.0.1:7890"
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/cython/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/cython/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/cython/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/cython/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/cython/
Could not fetch URL https://pypi.org/simple/cython/: There was a problem confirming the ssl certificate: SOCKSHTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/cython/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping
ERROR: Could not find a version that satisfies the requirement Cython==0.29.17 (from versions: none)
ERROR: No matching distribution found for Cython==0.29.17
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: SOCKSHTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping
WARNING: There was an error checking the latest version of pip.
则换个源即可:
pip install -r requirements.txt --proxy="socks5://127.0.0.1:7890" -i https://mirror.baidu.com/pypi/simple
linux环境变量设置代理:
$ export http_proxy=http://proxy.xxxx.com:8080
$ export https_proxy=http://proxy.xxxx.com:8080
当然,之后我们可能想不用这个代理,该怎么搞呢?
# 先看一下本机有哪些代理:
env | grep -i proxy
$ export http_proxy=http://proxy.xxxx.com:8080
$ export https_proxy=http://proxy.xxxx.com:8080
取消http的代理:
unset http_proxy
取消https的代理:
unset https_proxy
摘自:
https://blog.csdn.net/weixin_42237113/article/details/108667768
pip更改默认镜像源
给 pip 换源
pip的配置文件在linux系统中为:
~/.pip/pip.conf
若上述配置文件不存在,则手动创建。
也可通过下面的命令查看配置文件位置:
pip -v config list
找到pip的配置文件后,以阿里云镜像为例,修改文件内容为:
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
trusted-host=mirrors.aliyun.com
以下是windows
系统的
进入AppData
目录
文件管理地址栏输入%APPDATA%
,即可快速进入。
如果你的用户是Administrator
可以使用下列地址手动进入:
C:\Users\Administrator\AppData\Roaming
新建pip目录
新建配置文件
在刚刚新建的pip
目录中,新建pip.ini
文件,文件内容如下:
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com