conda安装和镜像源配置
# 安装
Miniconda清华源 (opens new window)
bash Miniconda-3.9.1-Linux-x86_64.sh -b -u -p /usr/local/miniconda3
1
# 配置
#生成配置文件
conda config
1
2
2
# 查看当前源
conda config --show channels
1
# 替换源
conda config --add channels https://xxxxxxxxxxxxxxx
1
针对清华源和腾讯源替换的方法
清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
1
2
3
4
5
2
3
4
5
腾讯源
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/pkgs/free/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/pkgs/main/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.cloud.tencent.com/anaconda/pkgs/pro/
1
2
3
4
5
2
3
4
5
# 移除源
conda config --remove channels https://xxxxxxxxxxxxxxx
1
针对清华源和腾讯源移除的方法
清华源
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --remove channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
1
2
3
4
5
2
3
4
5
腾讯源
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/pkgs/free/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/pkgs/main/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/cloud/conda-forge/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/cloud/pytorch/
conda config --remove channels https://mirrors.cloud.tencent.com/anaconda/pkgs/pro/
1
2
3
4
5
2
3
4
5
# 使用配置文件修改
使用文档编辑工具打开 ~/.condarc 文件,即可手动修改配置信息。
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro/
- defaults
show_channel_urls: true
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 使用 conda
创建一个新的虚拟环境,并安装兼容的 Python 版本
conda create -n tf2 python=3.9
conda activate tf2
1
2
2
# 导出现有环境的python依赖
python -m pip freeze > requirements.txt
pip install -r requirements.txt
#指定镜像源安装
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
1
2
3
4
2
3
4
上次更新: 2024/11/15, 16:53:03