Featured image of post Ubuntu-service-2024安装miniconda管理python环境

Ubuntu-service-2024安装miniconda管理python环境

Ubuntu-service-2024安装miniconda管理python环境

安装miniconda

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 下载
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

# 加执行权限
chmod +x Miniconda3-latest-Linux-x86_64.sh

# 运行
./Miniconda3-latest-Linux-x86_64.sh
# 建议conda init  yes

# 然后退出终端, 重新连接,加载环境变量或者
source ~./bashrc  # 注意这一步要在bash环境,不能是fish之类的

conda管理python虚拟环境

conda换源

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# conda 换源
# 添加清华源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
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/r/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/

# 设置显示源地址
conda config --set show_channel_urls yes

# 移除默认源(可选)
conda config --remove channels defaults

管理虚拟环境

1
2
3
4
5
# 创建名为 MyEnvName  3.11 版本的python
conda create -n MyEnvName python=3.11

# 删除虚拟环境
conda remove MyEnvName

虚拟环境中pip换源

1
2
3
4
5
6
7
# 激活虚拟环境
conda activate MyEnvName 
# bash环境中激活, 激活成功后可以启动fish等,也是激活状态

# pip 换源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn
使用 Hugo 构建
主题 StackJimmy 设计