【问题标题】:Anaconda python: PackagesNotFoundError error when trying to roll back revisionAnaconda python:尝试回滚修订时出现PackagesNotFoundError错误
【发布时间】:2019-05-17 16:50:15
【问题描述】:

出于某种原因,我决定升级setuptools。我跑conda install -c anaconda setuptools时弹出的所谓打包计划如下:

The following packages will be downloaded:

  package                    |            build
  ---------------------------|-----------------
  certifi-2019.3.9           |           py37_0         155 KB  anaconda
  pip-19.1.1                 |           py37_0         1.8 MB  anaconda
  python-3.7.2               |      h8c8aaf0_10        17.7 MB  anaconda
  setuptools-41.0.1          |           py37_0         680 KB  anaconda
  wheel-0.33.4               |           py37_0          57 KB  anaconda
  wincertstore-0.2           |           py37_0          13 KB  anaconda
  ------------------------------------------------------------
                                       Total:        20.4 MB

The following NEW packages will be INSTALLED:

   pip                anaconda/win-64::pip-19.1.1-py37_0

The following packages will be UPDATED:

  certifi     2018.11.29-py36_0 --> 2019.3.9-py37_0
  python      pkgs/main::python-3.6.4-h6538335_1 --> anaconda::python-3.7.2-h8c8aaf0_10
  setuptools  pkgs/main::setuptools-38.4.0-py36_0 --> anaconda::setuptools-41.0.1-py37_0
  wheel       pkgs/main::wheel-0.30.0-py36h6c3ec14_1 --> anaconda::wheel-0.33.4-py37_0

The following packages will be SUPERSEDED by a higher-priority channel:

  wincertstore     pkgs/main::wincertstore-0.2-py36h7fe5~ --> anaconda::wincertstore-0.2-py37_0

但是,升级破坏了我的代码中真正需要且无法更新的其他部分。因此我决定回滚到之前的状态。 conda list --revisions 的最新修订是:

2019-02-12 15:10:38  (rev 12)
    bzip2  {1.0.6 (conda-forge) -> 1.0.6 (anaconda)}
    ca-certificates  {2018.03.07 -> 2019.1.23 (anaconda)}
    certifi  {2018.11.29 -> 2018.11.29 (anaconda)}
    conda  {4.5.12 -> 4.6.2 (anaconda)}
    nbconvert  {5.3.1 -> 5.4.0 (anaconda)}
    openssl  {1.1.1a -> 1.1.1 (anaconda)}
    snappy  {1.1.7 (conda-forge) -> 1.1.7 (anaconda)}
    vc  {14.1 -> 14.1 (anaconda)}
    vs2015_runtime  {14.15.26706 -> 15.5.2 (anaconda)}
    yaml  {0.1.7 (conda-forge) -> 0.1.7 (anaconda)}
    zlib  {1.2.11 (conda-forge) -> 1.2.11 (anaconda)}
   +defusedxml-0.5.0 (anaconda)

2019-05-17 16:52:29  (rev 13)
    certifi  {2018.11.29 (anaconda) -> 2019.3.9 (anaconda)}
    pip  {9.0.1 -> 19.1.1 (anaconda)}
    python  {3.6.4 -> 3.7.2 (anaconda)}
    setuptools  {38.4.0 -> 41.0.1 (anaconda)}
    wheel  {0.30.0 -> 0.33.4 (anaconda)}
    wincertstore  {0.2 -> 0.2 (anaconda)}

现在的问题是,当我执行conda install --revision 12 时,出现以下错误:

PackagesNotFoundError: The following packages are missing from the target environment:
    - anaconda::certifi==2018.11.29=py36_0

请问有什么办法可以回滚吗?

非常感谢

【问题讨论】:

    标签: python python-3.x anaconda


    【解决方案1】:

    看来您正在通过以下方式维护环境 发出一系列conda install 命令。 你可以继续这样做, 在命令行上有一个额外的版本规范。 但我鼓励您改用这种方法:

    创建一个如下所示的environment.yml 文件。

    name: myproject
    
    channels:
      - conda-forge
    
    dependencies:
      - bzip2 >= 1.0.6
      - pip >= 19.1.1
      - snappy >= 1.1.7
      - zlib >= 1.2.11
    

    根据需要添加其他人。

    使用conda env update 安装软件包。 (使用which python,您可以看到它们的安装位置。)

    这种方法的一个优点是您可以轻松地 rm -rf ~/miniconda3/envs/myproject/ (或安装在哪里) 然后conda env update 从头开始​​重新安装。 这通常可以解决版本炎问题, 或者至少提供一个提示 关于应该放宽哪些版本约束 允许一个可行的解决方案。

    【讨论】:

      【解决方案2】:

      以防万一有人碰到这种情况,面对类似的情况,这是我所做的,公平地说,这实际上并不是回滚。看来我的 conda 环境确实搞砸了我在原始帖子中提到的升级,因为当我执行 conda update conda 时,我收到以下错误:

      >conda update conda
      Collecting package metadata: done
      Solving environment: | WARNING 
      conda.common.logic:get_sat_solver_cls(289): Could not run SAT solver through interface "pycosat".
      WARNING conda.common.logic:get_sat_solver_cls(289): Could not run SAT solver through interface "pycryptosat".
      WARNING conda.common.logic:get_sat_solver_cls(289): Could not run SAT solver through interface "pysat".failed
      

      我的 numpy 也坏了,谁知道还有什么......

      我按照 Kale Franz 在此链接中描述的步骤进行操作:https://github.com/conda/conda/issues/7714#issuecomment-417553149

      为了完整起见,我在下面附上他的回答截图:

      运行 Kale 在他的帖子中建议的命令,我得到了一长串导致不一致的软件包。我的清单真的很长,我只是粘贴在前几行下面:

      Collecting package metadata: done
      Solving environment: \
      The environment is inconsistent, please check the package plan carefully
      The following packages are causing the inconsistency:
      
        - defaults/win-64::alabaster==0.7.10=py36hcd07829_0
        - defaults/win-64::anaconda-client==1.6.9=py36_0
        - defaults/win-64::anaconda==custom=py36h363777c_0
        - defaults/win-64::anaconda-project==0.8.2=py36hfad2e28_0
        - defaults/win-64::asn1crypto==0.24.0=py36_0
        - defaults/win-64::astroid==1.6.1=py36_0
          .... (A lot more that I am not pasting here) ....
      

      列表结束后,消息继续如下:

      The following packages will be downloaded:
      
      package                    |            build
      ---------------------------|-----------------
      ca-certificates-2019.5.15  |                0         166 KB
      certifi-2019.3.9           |           py36_0         156 KB
      cffi-1.12.3                |   py36h7a1dbc1_0         225 KB
      chardet-3.0.4              |           py36_1         210 KB
      conda-4.6.14               |           py36_0         2.1 MB
      cryptography-2.7           |   py36h7a1dbc1_0         564 KB
      idna-2.8                   |           py36_0         134 KB
      menuinst-1.4.16            |   py36he774522_0         227 KB
      openssl-1.1.1c             |       he774522_1         5.7 MB
      pip-19.1.1                 |           py36_0         1.9 MB
      pycosat-0.6.3              |   py36hfa6e2cd_0          98 KB
      pycparser-2.19             |           py36_0         174 KB
      pyopenssl-19.0.0           |           py36_0          82 KB
      pysocks-1.7.0              |           py36_0          30 KB
      python-3.6.8               |       h9f7ef89_7        20.3 MB
      pywin32-223                |   py36hfa6e2cd_1         9.3 MB
      requests-2.22.0            |           py36_0          90 KB
      ruamel_yaml-0.15.46        |   py36hfa6e2cd_0         262 KB
      setuptools-41.0.1          |           py36_0         663 KB
      six-1.12.0                 |           py36_0          22 KB
      urllib3-1.24.2             |           py36_0         153 KB
      wheel-0.33.4               |           py36_0          57 KB
      win_inet_pton-1.1.0        |           py36_0           9 KB
      wincertstore-0.2           |   py36h7fe50ca_0          13 KB
      ------------------------------------------------------------
                                             Total:        42.6 MB
      
      The following packages will be UPDATED:
      
        ca-certificates     anaconda::ca-certificates-2019.1.23-0 --> pkgs/main::ca-certificates-2019.5.15-0
        cffi                                1.11.4-py36hfa6e2cd_0 --> 1.12.3-py36h7a1dbc1_0
        conda                        anaconda::conda-4.6.2-py36_0 --> pkgs/main::conda-4.6.14-py36_0
        cryptography                         2.4.2-py36h7a1dbc1_0 --> 2.7-py36h7a1dbc1_0
        idna                                   2.6-py36h148d497_1 --> 2.8-py36_0
        menuinst                            1.4.11-py36hfa6e2cd_0 --> 1.4.16-py36he774522_0
        pycparser                             2.18-py36hd053e01_1 --> 2.19-py36_0
        pyopenssl                           17.5.0-py36h5b7d817_0 --> 19.0.0-py36_0
        pysocks                              1.6.7-py36h698d350_1 --> 1.7.0-py36_0
        pywin32                                222-py36hfa6e2cd_0 --> 223-py36hfa6e2cd_1
        requests                            2.18.4-py36h4371aae_1 --> 2.22.0-py36_0
        ruamel_yaml                        0.15.35-py36hfa6e2cd_1 --> 0.15.46-py36hfa6e2cd_0
        six                                 1.11.0-py36h4db2310_1 --> 1.12.0-py36_0
        urllib3                               1.22-py36h276f60a_0 --> 1.24.2-py36_0
        win_inet_pton                        1.0.1-py36he67d7fd_1 --> 1.1.0-py36_0
      
      The following packages will be SUPERSEDED by a higher-priority channel:
      
      certifi                 anaconda::certifi-2019.3.9-py37_0 --> pkgs/main::certifi-2019.3.9-py36_0
      openssl                anaconda::openssl-1.1.1-he774522_0 --> pkgs/main::openssl-1.1.1c-he774522_1
      pip                           anaconda::pip-19.1.1-py37_0 --> pkgs/main::pip-19.1.1-py36_0
      python                 anaconda::python-3.7.2-h8c8aaf0_10 --> pkgs/main::python-3.6.8-h9f7ef89_7
      setuptools             anaconda::setuptools-41.0.1-py37_0 --> pkgs/main::setuptools-41.0.1-py36_0
      wheel                       anaconda::wheel-0.33.4-py37_0 --> pkgs/main::wheel-0.33.4-py36_0
      wincertstore            anaconda::wincertstore-0.2-py37_0 --> pkgs/main::wincertstore-0.2-py36h7fe50ca_0
      
      The following packages will be DOWNGRADED:
      
       chardet                              3.0.4-py36h420ce6e_1 --> 3.0.4-py36_1
       pycosat                              0.6.3-py36h413d8a4_0 --> 0.6.3-py36hfa6e2cd_0
      
      
      Proceed ([y]/n)? y
      

      现在一切看起来都很好,如果我这样做 conda list --revisions 我最近的两个修订是:

       2019-05-17 16:52:29  (rev 13)
           certifi  {2018.11.29 (anaconda) -> 2019.3.9 (anaconda)}
           pip  {9.0.1 -> 19.1.1 (anaconda)}
           python  {3.6.4 -> 3.7.2 (anaconda)}
           setuptools  {38.4.0 -> 41.0.1 (anaconda)}
           wheel  {0.30.0 -> 0.33.4 (anaconda)}
           wincertstore  {0.2 -> 0.2 (anaconda)}
      
       2019-06-10 14:05:10  (rev 14)
           ca-certificates  {2019.1.23 (anaconda) -> 2019.5.15}
           certifi  {2019.3.9 (anaconda) -> 2019.3.9}
           cffi  {1.11.4 -> 1.12.3}
           chardet  {3.0.4 -> 3.0.4}
           conda  {4.6.2 (anaconda) -> 4.6.14}
           cryptography  {2.4.2 -> 2.7}
           idna  {2.6 -> 2.8}
           menuinst  {1.4.11 -> 1.4.16}
           openssl  {1.1.1 (anaconda) -> 1.1.1c}
           pip  {19.1.1 (anaconda) -> 19.1.1}
           pycosat  {0.6.3 -> 0.6.3}
           pycparser  {2.18 -> 2.19}
           pyopenssl  {17.5.0 -> 19.0.0}
           pysocks  {1.6.7 -> 1.7.0}
           python  {3.7.2 (anaconda) -> 3.6.8}
           pywin32  {222 -> 223}
           requests  {2.18.4 -> 2.22.0}
           ruamel_yaml  {0.15.35 -> 0.15.46}
           setuptools  {41.0.1 (anaconda) -> 41.0.1}
           six  {1.11.0 -> 1.12.0}
           urllib3  {1.22 -> 1.24.2}
           wheel  {0.33.4 (anaconda) -> 0.33.4}
           win_inet_pton  {1.0.1 -> 1.1.0}
           wincertstore  {0.2 (anaconda) -> 0.2}
      

      【讨论】:

        【解决方案3】:

        我同意 J_H,最好的办法是在代码版本控制系统 (Git) 中保留使用 conda env export > environment.yml 生成的 environment.yml。然后如果出现问题,您可以删除您的环境并使用conda env create -f environment.yml 重新创建它(但不能使用conda env update)。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-09-12
          • 2022-09-28
          • 2016-10-18
          • 1970-01-01
          • 2022-10-01
          • 2017-08-30
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多