Anaconda安装、升级、使用、镜像、激活环境
安装
1
bash Anaconda3-2019.07-Linux-x86_64.sh
升级
升级anaconda前需要升级conda
1 2 3
conda update conda #基本升级 conda update anaconda #大的升级 conda update anaconda-navigator //update最新版本的anaconda-navigator
conda环境使用基本命令
1 2 3 4 5 6 7 8 9 10 11
conda update -n base conda #update最新版本的conda conda create -n xxxx python=3.7 #创建python3.7的xxxx虚拟环境 conda activate xxxx #开启xxxx环境 conda deactivate #关闭环境 conda env list #显示所有的虚拟环境 conda info --envs #显示所有的虚拟环境 conda create --name newname --clone oldname #克隆环境 conda remove --name oldname --all #彻底删除旧环境 conda install tensorflow=1.8.0 #安装特定版本的包 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyterthemes #清华源下载更快 conda install nb_conda #安装后便可以在jupyter选择环境
conda更新卸载安装包
1 2 3 4
conda list #查看已经安装的文件包 conda list -n xxx #指定查看xxx虚拟环境下安装的package conda update xxx #更新xxx文件包 conda uninstall xxx #卸载xxx文件包
conda安装本地包
1 2 3 4
#pip 安装本地包 pip install ~/Downloads/a.whl #conda 安装本地包 conda install --use-local ~/Downloads/a.tar.bz2
修改镜像源
1 2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
然后在.condarc修改内容如下,亲测有效:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
channels: - defaults show_channel_urls: true channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud ssl_verify: true
conda自动开启/关闭激活
1 2 3 4 5
conda activate #默认激活base环境 conda activate xxx #激活xxx环境 conda deactivate #关闭当前环境 conda config --set auto_activate_base false #关闭自动激活状态 conda config --set auto_activate_base true #关闭自动激活状态
jupyter notebook设置
默认目录设置:
linux打开.jupyter/jupyter_notebook_config.py文件,windows用如下命令:
1 2
jupyter notebook --generate-config #会生成文件C:\Users\用户\.jupyter\jupyter_notebook_config.py
通过搜索关键词c.NotebookApp.notebook_dir,修改如下
1
c.NotebookApp.notebook_dir = 'E:\\tf_models' #修改到自定义文件夹
然后重启notebook服务器就可以了
linux环境配置:
1 2
export PATH=/home/hadoop/anaconda3/bin:$PATH unset XDG_RUNTIME_DIR