Conda可以回滚?

作者: 王诗翔 | 来源:发表于2019-02-25 11:06 被阅读1次

    Yes。

    不得不佩服这帮开发conda的程序员,使用Conda可以回滚(rollback)到上一次的安装状态,而且还非常简单。


    我在某个环境安装某个软件后,我以为没有依赖这个环境的软件,所以一路yes,结果python从2.7上升到了3.6,还有其他几个包被增加和更新。结果我有些软件用不了了!还好一查,Conda提供了回滚的功能特性。

    查看conda更新历史

    使用conda list --revision

    $ conda list --revision
    2018-11-19 19:22:48  (rev 0)
        +ca-certificates-2018.03.07 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +certifi-2018.10.15 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +libedit-3.1.20170329 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +libffi-3.2.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +libgcc-ng-8.2.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +libstdcxx-ng-8.2.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +ncurses-6.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +openssl-1.1.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +pip-18.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +python-2.7.15 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +readline-7.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +setuptools-40.5.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +sqlite-3.25.2 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +tk-8.6.8 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +wheel-0.32.2 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +zlib-1.2.11 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
    
    2018-11-20 14:51:23  (rev 1)
        +libfuse-3.2.5 (jessetg/label/sbu-hpc)
    
    2018-11-20 14:54:48  (rev 2)
        +java-jdk-8.0.112 (bioconda)
        +openjdk-8.0.112 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge)
    
    2018-11-20 15:14:39  (rev 3)
         openjdk  {8.0.112 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge) -> 8.0.152 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)}
        -java-jdk-8.0.112 (bioconda)
    
    2019-02-25 10:19:10  (rev 4)
         ca-certificates  {2018.03.07 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main) -> 2019.1.23 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)}
         certifi  {2018.10.15 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main) -> 2018.11.29 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)}
         pip  {18.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main) -> 19.0.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)}
         python  {2.7.15 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main) -> 3.6.7 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)}
         setuptools  {40.5.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main) -> 40.8.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)}
         wheel  {0.32.2 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main) -> 0.32.3 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)}
        +asn1crypto-0.24.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +cffi-1.11.5 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +chardet-3.0.4 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +cryptography-2.5 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +idna-2.8 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +pycparser-2.19 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +pyega3-3.0.21 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda)
        +pyopenssl-19.0.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +pysocks-1.6.8 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +requests-2.21.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +six-1.12.0 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +tqdm-4.31.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +urllib3-1.24.1 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
        +xz-5.2.4 (https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main)
    
    

    可以看到rev 4就是我今天做的更改。要改回rev 3也很简单。

    回滚

    使用conda install --version N,N这里是指更改历史的序号。

    $ conda install --revision 3
    
    ## Package Plan ##
    
      environment location: /public/home/liuxs/anaconda3/envs/icgc
    
      added / updated specs: 
        - libfuse
        - pyega3
    
    
    The following packages will be REMOVED:
    
        asn1crypto:      0.24.0-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        cffi:            1.11.5-py36he75722e_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        chardet:         3.0.4-py36_1          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        cryptography:    2.5-py36h1ba5d50_0    https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        idna:            2.8-py36_0            https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        pycparser:       2.19-py36_0           https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        pyega3:          3.0.21-py36_1         https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda
        pyopenssl:       19.0.0-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        pysocks:         1.6.8-py36_0          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        requests:        2.21.0-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        six:             1.12.0-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        tqdm:            4.31.1-py_0           https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        urllib3:         1.24.1-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
        xz:              5.2.4-h14c3975_4      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main     
    
    The following packages will be DOWNGRADED:
    
        ca-certificates: 2019.1.23-0           https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main      --> 2018.03.07-0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
        certifi:         2018.11.29-py36_0     https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main      --> 2018.10.15-py27_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
        pip:             19.0.1-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main      --> 18.1-py27_0       https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
        python:          3.6.7-h0371630_0      https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main      --> 2.7.15-h9bab390_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
        setuptools:      40.8.0-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main      --> 40.5.0-py27_0     https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
        wheel:           0.32.3-py36_0         https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main      --> 0.32.2-py27_0     https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    
    Proceed ([y]/n)? y
    
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done
    
    

    Conda大法好。

    参考:

    相关文章

      网友评论

        本文标题:Conda可以回滚?

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