conda 配置代理服务器

conda 配置代理服务器需要在 ~/.condarc 这个文件里配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
- defaults
show_channel_urls: true
custom_channels:
conda-forge: https://mirrors.bfsu.edu.cn/anaconda/cloud
msys2: https://mirrors.bfsu.edu.cn/anaconda/cloud
# xxx: yyyyyy
ssl_verify: false
proxy_server:
http: # 这里配置公司内网的 proxy server
https: # 例如:http://[Account]:[Passwrod]@proxyhk.huawei.com:8080

pip 配置代理服务器

pip 需要在 ~/.pip/pip.conf 这个文件里配置。Linux 的配置文件在 ~/.pip/pip.conf,Windows 为

  • AnaConda: C:/Users/[Username]/pip/pip.ini
  • MiniConda: C:/Users/[Username]/AppData/Roaming/pip/pip.ini

添加:

1
2
3
4
[global]
index-url = # 代理服务器地址。例如 https://mirror.tools.huawei.com/pypi/simple
trusted-host = # 主机域名。例如 mirror.tools.huawei.com
timeout = 120

uv 包管理器添加 indexing

uv init 初始化本地目录后,修改 pyprojects.toml 添加下面的条目

1
2
3
[[tool.uv.index]]
url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/" # 这个是清华大学的 pip 软件包源
default = true