新手Ubuntu常见问题汇总

本文档详细介绍了在Ubuntu系统中使用Conda进行环境管理的步骤,包括创建、激活、安装包、关闭及删除虚拟环境,并提供了更换国内源的教程,确保更快的下载速度。此外,还讲解了如何查看系统资源使用情况以及解决conda安装失败的问题。对于想要深入了解和高效使用Conda的Ubuntu新手来说,这是一个实用的参考资料。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

新手Ubuntu常见问题汇总

一. conda查看命令

conda env list 或 conda info -e 查看当前存在哪些虚拟环境
conda list -n your_env_name 查看your_env_name 已经安装的包
conda list 查看当前环境下安装了哪些包。
conda update conda 检查更新当前conda
conda updata anaconda 检查更新当前anaconda

二. 虚拟环境

1. 创建
conda create -n xxx python=3.6 # xxx代表环境的名称, python=3.6 代表python创建的版本
2. 使用激活(或切换)虚拟环境
python --version # 检查当前的python版本
Linux: source activate your_env_name # your_env_name--虚拟环境的名称
Windows: activate your_env_name
Ubuntu: conda activate your_env_name
3. 虚拟环境安装额外的包
conda install package # 默认当前环境
conda install -n your_env_name package # 指定your_env_name环境安装包, 也可以通过-c制定某个channel安装
4.关闭虚拟环境
Linux: source deactive
Windows: deactivate
Ubuntu: conda deactivate
5. 删除虚拟环境
conda remove -n your_env_name -all # 删除环境
conda remove --name your_env_name package_name # 删除环境中的某个包

三. Conda 换国内源

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/cloud/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

# 设置收索时显示通道地址
conda config --set show_channel_urls yes
conda config --show channels # 查看镜像源命令
conda config --remove-key channels # 移除镜像源命令

注意如果需要pytorch, 还需要添加pytorch的镜像

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
2. 添加中科大源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
conda config --set show_channel_urls yes

四. 查看当前系统资源使用情况

nvidia-smi

五. 创建conda install -n your_env_name python=3.6失败

关闭代理服务器

export | grep -i prox # 第一步, 查看HTTP
unset HTTPS_PROXY # 第二步 关闭HTTP
unset HTTP_PROXY
unset NO_PROXY
unset http_proxy
unset https_proxy
imset no_proxy # 全部关闭, 虚拟环境创建成功

六. anconda克隆环境

查看环境名称

conda info --envs

克隆环境

conda create -n 新名称 --clone 被克隆环境
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Fighting_1997

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值