安装 conda
安装
sh
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -u一路 Enter 和 yes。
初始化 conda
如果没有自动初始化,手动执行:
sh
conda init或者在 .bashrc 或 .zshrc 中添加:
sh
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/asimov/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/asimov/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/asimov/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/asimov/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<重启终端:bash 或 zsh。
测试 conda 版本
sh
conda --version添加国内源
Anaconda - USTC Mirror Help
anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
sh
# conda config --show-sources
nano ~/miniconda3/.condarc修改为如下内容:
yaml
channels:
- nodefaults
custom_channels:
conda-forge: https://mirrors.ustc.edu.cn/anaconda/cloud
bioconda: https://mirrors.ustc.edu.cn/anaconda/cloud
show_channel_urls: true清除缓存:
sh
conda clean -i测试:
sh
# 详见:创建 conda env
# conda create -n myenv numpy -c conda-forge创建 conda env
See: How to pick python 3.11 as a conda environment in vs code - Stack Overflow
sh
# conda create --name ai python
# conda create --name ai python=3.11
conda create --name ai python=3.13.9 -c conda-forge
conda activate ai
conda deactivate删除 conda env
sh
conda deactivate
conda env remove --name ai测试 python 版本
sh
which python
python --version添加 alias
在 ~/.bash_aliases 或 ~/.zshrc 中添加:
sh
alias cda="conda activate ai"
alias cdd="conda deactivate"默认进入 conda env
在 ~/.bashrc 或 ~/.zshrc 中添加:
sh
conda activate ai