• conda


    简介https://blog.csdn.net/koflance/article/details/78582737

    conda类似于npm或maven的包管理工具,只是conda是针对于python的。可以安装minconda或anaconda进行安装,前者是简化版本,只包含conda和其依赖。如果安装环境有python相关包也没有关系,不需要进行卸载。

    anaconda支持windows、mac和linux系统,且有两个类型的版本,分别是GUI和command line版本,前者是图形界面,后者是命令行界面,占用资源较少。

    conda有python3.x和python2.x系列两个版本,其实都没有关系,因为你在使用conda进行创建环境时,可以指定python的版本。

    安装教程: 
    https://conda.io/docs/user-guide/install/index.html#installing-conda-on-a-system-that-has-other-python-installations-or-packages

    命令

    注意: 一般情况,–后面接长单词的参数等同于,-接单个字母的参数

    • 判断版本
    conda --version
    ## 或者
    conda -V
    
    ## 如果要更新版本
    conda update conda
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 查看帮助信息
    conda --help
    conda -h
    • 1
    • 2
    • 针对环境的操作(conda通过环境来隔离不同package的版本问题)

    不同环境安装在~/anacoda2/envs/xxx目录中

    1、创建环境
    conda create --name [name] [dependent package list]
    
    例如:
    conda create --name snowflakes biopython
    指定了python版本
    conda create --name bunnies python=3.5 astroid babel
    
    2、从其他环境拷贝到新的环境
    conda create --name flowers --clone snowflakes
    
    3、激活环境
        •   Linux and macOS: source activate snowflakes
        •   Windows: activate snowflakes
    
    4、列出当前环境
    conda info --envs
    
    ali-186590cc30b9:~ liujun$ conda info --envs
    # conda environments:
    #
    snowflakes               /Users/liujun/anaconda2/envs/snowflakes
    root                  *  /Users/liujun/anaconda2
    
    5、失效环境,或切换到root环境
        •   Linux, macOS: source deactivate
        •   Windows: deactivate
    
    6、删除指定环境
    conda remove --name flowers --all
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 包管理命令
    1、查询可用包版本信息
    conda search --full-name python
    conda search beautifulsoup4
    
    
    查询在线包链接:
    https://anaconda.org/
    
    2、查询当前环境中的包列表
    conda list
    
    3、在环境中安装包
    conda install numpy=1.13.3
    conda install --name [环境名称] beautifulsoup4
    指定下载地址方式安装
        1.  In a browser, go to http://anaconda.org.

        2.  Look for a package named “bottleneck”:
        1.  In the top-left corner of the screen, in the Search Anaconda Cloud box, type bottleneck.
        2.  Click the Search button.
        3.  There are more than a dozen copies of bottleneck available on Anaconda.org, but you want the most frequently downloaded copy.

        4.  Click the Downloads column heading to sort the results by number of downloads.

        5.  Click the package name of the version that has the most downloads.
The Anaconda.org detail page appears, showing the command to use to download the package:
    
        conda install -c conda-forge bottleneck
    
        6.  Run the displayed command.

    
    使用pip工具安装
    
    pip只是一个包管理工具,不同于conda,是无法识别环境的,而且无法更新python,pip认为python不是一个包。但pip可以安装一些conda无法安装的包,pip已经随着anaconda和minconda安装好了。
    
    安装命令
    pip install see
    
    4、删除包
    conda remove --name [环境名称] iopro
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37

    命令列表地址: 
    https://conda.io/docs/commands.html

    配置

    类似于maven的setting.xml文件,conda也有一个配置文件(yaml格式),名字是.condarc,该文件可以指定包搜索的url地址、proxy配置和环境目录。anacoda的安装目录其实在/Users/xxx/anaconda2,因此配置文件也在~目录。各个环境自身也有个配置文件,地址为~/anaconda2/envs/[环境名称]/.condarc

    配置方式有两种:使用conda config命令、用文本编辑器

    配置样例: 
    https://conda.io/docs/user-guide/configuration/sample-condarc.html

    # This is a sample .condarc file.
    # It adds the r Anaconda.org channel and enables
    # the show_channel_urls option.
    
    # channel locations. These override conda defaults, i.e., conda will
    # search *only* the channels listed here, in the order given.
    # Use "defaults" to automatically include all default channels.
    # Non-url channels will be interpreted as Anaconda.org usernames
    # (this can be changed by modifying the channel_alias key; see below).
    # The default is just 'defaults'.
    channels:
      - r
      - defaults
    
    # Show channel URLs when displaying what is going to be downloaded
    # and in 'conda list'. The default is False.
    show_channel_urls: True
    
    # For more information about this file see:
    # https://conda.io/docs/user-guide/configuration/use-condarc.html
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • conda config命令
    conda config --get 显示所有的配置
    conda config --get [key1] [key2] 显示指定配置
    conda config --add [key] [value] 添加新配置
    conda config --set [key] [value] 设置配置
    conda config --remove [key] [value] 删除一个配置
    conda config --remove-key [key] 删除一个key
    
    
    查看命令列表
    conda config --help
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    部分key值说明

    • 配置包仓库
    可以指定多个仓库地址,其中default别名特指https://conda.anaconda.org/仓库,搜索时会按照顺序搜索
    例如:
    channels:
      - <anaconda_dot_org_username>
      - http://some.custom/channel
      - file:///some/local/directory
      - defaults
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 显示下载包的地址

    使用conda list时,在列表中展示的当前环境已下载包的来源channel,该值默认是false,如果需要设置,需执行以下命令:

    conda config --set show_channel_urls true
    • 1
    • 设置默认加载包

    create_default_packages参数可以设置每次创建环境时,默认加载的包。当然也可以在创建envs时,指定–no-default-packages禁用。

    • 禁止更新包

    默认情况下,conda会更新环境中的所有包及其依赖至最新版本(在创建时指定了版本除外,例如conda install numpy=1.9.3),需要指定update_dependencies为true,这样conda会依赖你的配置只对指定的包进行更新。当然在创建envs时,也可以用–update-dependencies或–no-update-dependencies进行指定。

    也可以使用pining文件方式禁止更新,参考链接:https://conda.io/docs/user-guide/tasks/manage-pkgs.html#pinning-packages

    删除

    rm -rf ~/miniconda
    rm -rf ~/.condarc ~/.conda ~/.continuum
  • 相关阅读:
    silverlight 跨域文件位置
    Asp.net弹出新窗口,获得返回值
    开通CNblog咯。
    访问IIS元数据库失败
    li可以显示多列
    [转]vs2005 sp1 下载地址、安装方法更新非常慢
    英特尔未来教育核心课程
    很好用的软键盘
    CMD里显示彩色文字
    将输入的中文按要求翻译成拼音
  • 原文地址:https://www.cnblogs.com/yizhixuepython/p/9306993.html
Copyright © 2020-2023  润新知