conda创建python虚拟环境

360 阅读1分钟

conda创建python虚拟环境

conda常用命令

conda list 查看安装了哪些包。
conda env list 或 conda info -e 查看当前存在哪些虚拟环境
conda update conda 检查更新当前conda

创建虚拟环境

conda create -n 虚拟环境名 python=3.6

激活虚拟环境

linux:
source activate your_env_name(虚拟环境名称)
windows:
activate your_env_name(虚拟环境名称)

虚拟环境中安装额外的包

conda install -n your_env_name [package]

关闭虚拟环境

Linux: source deactivate

Windows: deactivate

删除虚拟环境

conda remove -n your_env_name(虚拟环境名称) --all
conda remove --name your_env_name package_name # 删除环境中的某个包

配置国内镜像
http://Anaconda.org的服务器在国外,安装多个packages时,conda下载的速度经常很慢。清华TUNA镜像源有Anaconda仓库的镜像,将其加入conda的配置即可:

# 添加Anaconda的TUNA镜像

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

# TUNA的help中镜像地址加有引号,需要去掉

# 设置搜索时显示通道地址

conda config --set show_channel_urls yes

不好安装的库/找不到的库

conda install -c conda-forge easydict

其中-c conda-forge是指明在库conda-forge中下载这个pkg。