python-3.x 巨蟒:尝试回滚修订时出现PackagesNotFoundError错误

i34xakig  于 2022-12-05  发布在  Python
关注(0)|答案(4)|浏览(174)

出于某种原因,我决定升级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

你知道怎么回滚吗?
多谢

cl25kdpy

cl25kdpy1#

看起来您正在通过发出一系列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重新安装。这通常可以解决版本问题,或者至少提供了一个关于应该放宽哪些版本约束以允许可行解决方案的提示。
编辑
我个人喜欢我的环境中的.yml文件中的>=约束。当事情出错时,坚持使用现代版本有利于社区支持,并且有利于更新的速度,因为conda将只有少数现代版本需要考虑,而不是试图弄清楚python2可能如何使用依赖约束。它帮助我了解更新。然后在引入新的deps后重新运行自动化单元测试。
或者,如果需要,您可以定期存储==约束以锁定快照,例如bzip2 == 1.0.6。如果您尚未执行此操作,您 * 仍然 * 可以使用bzip2 >= 1.0.5 checkout 旧快照,并使用全局搜索和替换进行编辑。将>=更改为==。这将设置时间机器上的控件,以便在时间上回到一些一致的旧dep版本集。如果你的conda env update运行显示出一些粗糙的边缘,考虑核武器的环境,并重新填充它从头开始。通常一个干净的安装这样会运行得更顺利。

xt0899hw

xt0899hw2#

为了防止有人遇到类似的情况,这是我所做的,公平地说,它实际上不是一个回滚。而且,我的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

我的麻木也坏了,谁知道还有什么...。
我按照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}
carvr3hs

carvr3hs3#

我同意J_H的观点,最好的办法是把你的environment.yml保存在你的代码版本系统(Git)中,然后在出现问题的时候你可以删除你的环境,用conda env create -f environment.yml重新创建它(但不是用conda env update)。

mrwjdhj3

mrwjdhj34#

我遇到了一个类似的问题,我无法角色回旧版本。

conda install --revision N

我在以下样式中收到了类似的错误消息

PackagesNotFoundError: The following packages are missing from the target environment:
    - channel-name::package==v.v.v=build
    - ...

将通道添加到命令中会有所帮助

conda install --revision N -c channel-name

相关问题