新手Ubuntu常见问题汇总

新手Ubuntu常见问题汇总

[TOP]自身学习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 # 全部关闭, 虚拟环境创建成功
上一篇:为conda添加哈工大镜像源


下一篇:Pytorch深度学习实战教程(二):UNet语义分割网络