美文网首页
Linux018 conda虚拟环境

Linux018 conda虚拟环境

作者: caoqiansheng | 来源:发表于2020-08-18 14:03 被阅读0次

    1.conda的安装

    conda的介绍及安装详见:Linux010 Miniconda安装及使用

    2.虚拟环境 virtual environment

    虚拟环境就是把一部分内容独立出来,独立出来这部分也被称作“容器”,在这个容器中可以只安装我们需要的依赖包,各个容器之间互相隔离,互不影响。

    3.为什么要用虚拟环境

    在实际使用过程中,我们通常会根据自己的需求不断的更新或卸载相应的库,直接对基础环境操作会造成很多不必要的麻烦,管理也相当混乱,另外就是如果出现了bug,想要恢复环境,也是很麻烦的过程。

    4.conda虚拟环境操作

    4.1 conda命令用法
    • conda命令
    usage: conda [-h] [-V] command ...
    
    conda is a tool for managing and deploying applications, environments and packages.
    
    Options:
    
    positional arguments:
      command
        clean        Remove unused packages and caches.
        compare      Compare packages between conda environments.
        config       Modify configuration values in .condarc. This is modeled
                     after the git config command. Writes to the user .condarc
                     file (/home/caoqiansheng/.condarc) by default.
        create       Create a new conda environment from a list of specified
                     packages.
        help         Displays a list of available conda commands and their help
                     strings.
        info         Display information about current conda install.
        init         Initialize conda for shell interaction. [Experimental]
        install      Installs a list of packages into a specified conda
                     environment.
        list         List linked packages in a conda environment.
        package      Low-level conda package utility. (EXPERIMENTAL)
        remove       Remove a list of packages from a specified conda environment.
        uninstall    Alias for conda remove.
        run          Run an executable in a conda environment. [Experimental]
        search       Search for packages and display associated information. The
                     input is a MatchSpec, a query language for conda packages.
                     See examples below.
        update       Updates conda packages to the latest compatible version.
        upgrade      Alias for conda update.
    
    optional arguments:
      -h, --help     Show this help message and exit.
      -V, --version  Show the conda version number and exit.
    
    conda commands available from other packages:
      env
    
    • conda-env
    usage: conda-env [-h] {create,export,list,remove,update,config} ...
    
    positional arguments:
      {create,export,list,remove,update,config}
        create              Create an environment based on an environment file
        export              Export a given environment
        list                List the Conda environments
        remove              Remove an environment
        update              Update the current environment based on environment
                            file
        config              Configure a conda environment
    
    optional arguments:
      -h, --help            Show this help message and exit.
    
    conda commands available from other packages:
      env
    
    4.2 基本操作
    ## 创建新环境
    conda create -n env_name python=version
    ## 激活
    conda activate env_name 
    ## 查看
    conda env list
    ## 退出
    conda deactivate
    ## 删除
    conda remove -n  env_name --all
    ## 查看安装了哪些包。
    conda list
    ## 查看当前存在哪些虚拟环境
    conda env list 
    conda info -e
    

    相关文章

      网友评论

          本文标题:Linux018 conda虚拟环境

          本文链接:https://www.haomeiwen.com/subject/qbohjktx.html