Skip to content
This repository has been archived by the owner on Jan 12, 2019. It is now read-only.

简单的 Conda 入门 #4

Open
JackieMium opened this issue Mar 8, 2018 · 1 comment
Open

简单的 Conda 入门 #4

JackieMium opened this issue Mar 8, 2018 · 1 comment
Labels
Code Talk is chip, show me the code Linux Linux related 基础 很基础的东西
Milestone

Comments

@JackieMium
Copy link
Owner

2017-05-10 

我选择了 Miniconda,因为不喜欢 Anaconda 那种巨无霸全家桶。

官方文档地址:Managing environments


基础

安装 Miniconda 时,默认自带一个名为root的环境,可以直接使用

source activate root

即可激活。在环境内执行pip install fooconda install foo一样都将会为当前root环境装包

添加 conda 的 TUNA 镜像

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

# 搜索时显示Cheel的nn地址
conda config --set show_channel_urls yes

该命令会生成~/.condarc文件,记录对 conda 的配置,直接手动创建、编辑该文件是相同的效果。

为某个环境装包:

conda install --name bunnies beautiful-soup

查看某个环境中已经安装的所有包:

conda list -n snowflakes

删除某个环境中的某个包:

conda remove --name bunnies iopro

更新已安装的包(condapython本身也可能这样更新):

conda update biopython
# update all pkgs:
conda update --all

conda 环境管理

新建一个环境,使用2.7版本的 Python 并且命名为Python_27:

# create an env
conda create --name Python_27 python=2.7

激活/关闭环境:

source activate snowflakes
source deactivate snowflakes

查看当前已经存在的所有环境:

# list all envs
conda info --envs
# or
conda env list

此时已经激活的环境前面带有×标识

克隆一个已存在的环境env_orgenv_copy

# clone an env
conda create --name env_copy --clone org_env

删除一个环境:

# remove an env
conda remove --name flowers --all

导出环境到文件:为了方便其他人可以获得与你完全相同的环境,可以导出环境到文件。

  1. 激活这一环境:
source activate env_name
  1. 导出环境到文件:
conda env export > environment.yml

导出的文件会包含pipconda安装的包。

  1. 根据environment.yml新建环境
conda env create -f environment.yml

Bioconda

1. Install conda

Bioconda requires the conda package manager to be installed. If you have an Anaconda Python installation, you already have it. Otherwise, the best way to install it is with the Miniconda package. The Python 3 version is recommended.

2. Set up channels

After installing conda you will need to add the bioconda channel as well as the other channels bioconda depends on. It is important to add them in this order so that the priority is set correctly (that is, bioconda is highest priority).

The conda-forge channel contains many general-purpose packages not already found in the defaults channel. The r channel contains common R packages used as dependencies for bioconda packages.

conda config --add channels conda-forge
conda config --add channels defaults
conda config --add channels r
conda config --add channels bioconda
@JackieMium JackieMium added Linux Linux related 基础 很基础的东西 Code Talk is chip, show me the code labels Mar 8, 2018
@JackieMium JackieMium added this to the Migration milestone Mar 9, 2018
@JackieMium
Copy link
Owner Author

2018-08-10

我的 ~/.condarc 的内容:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
  - defaults
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/
#  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true
channel_priority: true

conda-forge 的 numpy 是 openblas 版,但 Debian 现在的一个 bug 的存在使得 openblas 暂时不可用,所以暂时禁用了 conda-forge。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Code Talk is chip, show me the code Linux Linux related 基础 很基础的东西
Projects
None yet
Development

No branches or pull requests

1 participant