conda 常用

2020-01-04

常用的命令

  1. 查看安装了哪些包

    conda list

  2. 查看当前存在哪些虚拟环境

    conda env list conda info -e

  3. 检查更新当前conda

    conda update conda

  4. Python创建虚拟环境

    conda create -n your_env_name python=x.x

anaconda命令创建python版本为x.x,名字为your_env_name的虚拟环境。your_env_name文件可以在Anaconda安装目录envs文件下找到。

  1. 激活或者切换虚拟环境

打开命令行,输入 python –version 检查当前 python 版本。

Linux:  source activate your_env_nam
Windows: activate your_env_name
  1. 对虚拟环境中安装额外的包

    conda install -n your_env_name [package]

  2. 关闭虚拟环境(即从当前环境退出返回使用PATH环境中的默认python版本)

    deactivate env_name

或者activate root切回root环境 Linux下:source deactivate

  1. 删除虚拟环境

    conda remove -n your_env_name –all

  2. 删除环境钟的某个包

    conda remove –name $your_env_name $package_name

  3. jupyter

如果 conda 环境不出现在 jupyter 选项中,可以按照如下方法处理:

nb_conda_kernels

 should be installed in the environment from which you run Jupyter Notebook or JupyterLab. This might be your base conda environment, but it need not be. For instance, if the environment notebook_env contains the notebook package, then you would run

conda install -n notebook_env nb_conda_kernels

Any other environments you wish to access in your notebooks must have an appropriate kernel package installed. For instance, to access a Python environment, it must have the ipykernel package; e.g.

conda install -n python_env ipykernel

To utilize an R environment, it must have the r-irkernel package; e.g.

conda install -n r_env r-irkernel

For other languages, their corresponding kernels must be installed.

参考

  1. https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook


文档信息 by XiaoPingYuan

版权声明:自由转载-非商用-非衍生-保持署名。发表日期:2020-01-04 by XiaoPingYuan(https://xesam.github.io/)