【问题标题】:resetting conda channel priorities重置 conda 通道优先级
【发布时间】:2018-07-10 20:25:42
【问题描述】:

我遇到了 conda 问题。运行命令后如:

conda install -c /my_conda_channel numpy --offline --override-channels

默认 conda 频道现在已变为“my_conda_channel”,因此该频道中的每个后续包都会取代默认频道,这不是我想要的。我做前者只是为了测试。

如何重置频道行为?

【问题讨论】:

    标签: anaconda conda channel


    【解决方案1】:

    转到您的主目录并在编辑器中打开.condarc。转到channels 并编辑优先级:

    channels:
      - defaults
      - my_conda_channel
    

    现在defaults 将优先于my_conda_channel。你也可以删除my_conda_channel

    【讨论】:

      【解决方案2】:

      ~/.condarc的顺序从defaults改为第一个频道

      channels:
        - defaults
        - conda-forge
      

      并将这一行添加到它

      channel_priority: true
      

      或在命令行中运行以下代码

      conda config --set channel_priority true
      

      然后再次运行

      conda update --all
      

      祝你好运


      针对新版本的 conda 进行了编辑。根据conda doc

      从 4.6.0 版开始,Conda 具有严格的通道优先级功能。严格的通道优先级可以显着加快 conda 操作并减少包不兼容问题。我们建议将其作为默认设置。但是,它可能会破坏旧的环境文件,因此我们计划将其设置为 conda 的开箱即用默认值,直到下一个主要版本更新 conda 5.0。

      channel_priority (ChannelPriority)
      Accepts values of 'strict', 'flexible', and 'disabled'.
      

      它仍然接受旧值 truefalse

      1. true := flexible
      2. false := disabled
      3. strict := 这是一个新值

      【讨论】:

      • 以 conda 开头 4.6.0channel_priority 接受 strictflexibledisabled 的值。 > 在以前的 conda 版本中,此参数配置为 TrueFalseTrue 现在是 flexible 的别名。请参阅docs.conda.io/projects/conda/en/latest/user-guide/tasks/…conda config --describe channel_priority
      【解决方案3】:

      另一种选择是将您的频道移至优先级列表的底部。
      运行命令....

      conda config --append channels my_conda_channel
      

      你应该得到这样的回应......

      Warning: 'my_conda_channel' already in 'channels' list, moving to the bottom
      

      验证...

      conda config --get channels
      

      这应该会给你类似...

      --add channels 'defaults'   # highest priority
      --add channels 'my_conda_channel'   # lowest priority
      

      【讨论】:

        【解决方案4】:

        在环境的 conda-meta 目录中,我添加了一个名为“pinned”的文件:

        固定:

        tensorflow               ==2.2.0
        tensorflow-base          ==2.2.0
        tensorflow-datasets      ==1.2.0
        tensorflow-estimator     ==2.2.0
        

        然后, conda update --all 没有更新包:

        $ conda update --all
        Collecting package metadata (current_repodata.json): - NVIDIA: no NVIDIA devices found
        done
        Solving environment: done
        
        
        ==> WARNING: A newer version of conda exists. <==
          current version: 4.8.4
          latest version: 4.9.1
        
        Please update conda by running
        
            $ conda update -n base -c defaults conda
        
        
        
        ## Package Plan ##
        
          environment location: /home/ubuntu/anaconda2/envs/ai
        
        
        The following packages will be downloaded:
        
            package                    |            build
            ---------------------------|-----------------
            awscli-1.18.169            |   py36h5fab9bb_0         1.8 MB  conda-forge
            boto3-1.16.9               |     pyhd8ed1ab_0          70 KB  conda-forge
            botocore-1.19.9            |     pyhd3deb0d_0         4.1 MB  conda-forge
            giflib-5.2.1               |       h36c2ea0_2          77 KB  conda-forge
            hypothesis-5.41.0          |     pyhd8ed1ab_0         222 KB  conda-forge
            jpeg-9d                    |       h36c2ea0_0         264 KB  conda-forge
            libpng-1.6.37              |       h21135ba_2         306 KB  conda-forge
            pandas-1.1.4               |   py36hd87012b_0        10.5 MB  conda-forge
            tornado-6.1                |   py36h1d69622_0         644 KB  conda-forge
            ------------------------------------------------------------
                                                   Total:        17.9 MB
        
        The following packages will be REMOVED:
        
          keras-applications-1.0.8-py_1
        
        The following packages will be UPDATED:
        
          awscli                            1.18.168-py36h5fab9bb_0 --> 1.18.169-py36h5fab9bb_0
          boto3                                 1.16.8-pyhd8ed1ab_0 --> 1.16.9-pyhd8ed1ab_0
          botocore                              1.19.8-pyhd3deb0d_0 --> 1.19.9-pyhd3deb0d_0
          hypothesis                            5.40.0-pyhd8ed1ab_0 --> 5.41.0-pyhd8ed1ab_0
          pandas                               1.1.3-py36h66e3816_2 --> 1.1.4-py36hd87012b_0
          tornado                              6.0.4-py36h8c4c3a4_2 --> 6.1-py36h1d69622_0
        
        The following packages will be DOWNGRADED:
        
          giflib                                   5.2.1-h516909a_2 --> 5.2.1-h36c2ea0_2
          jpeg                                        9d-h516909a_0 --> 9d-h36c2ea0_0
          libpng                                  1.6.37-hed695b0_2 --> 1.6.37-h21135ba_2
        
        
        Proceed ([y]/n)? y
        
        
        Downloading and Extracting Packages
        hypothesis-5.41.0    | 222 KB    | ######################################### | 100% 
        tornado-6.1          | 644 KB    | ######################################### | 100% 
        boto3-1.16.9         | 70 KB     | ######################################### | 100% 
        libpng-1.6.37        | 306 KB    | ######################################### | 100% 
        awscli-1.18.169      | 1.8 MB    | ######################################### | 100% 
        jpeg-9d              | 264 KB    | ######################################### | 100% 
        botocore-1.19.9      | 4.1 MB    | ######################################### | 100% 
        pandas-1.1.4         | 10.5 MB   | ######################################### | 100% 
        giflib-5.2.1         | 77 KB     | ######################################### | 100% 
        Preparing transaction: done
        Verifying transaction: done
        Executing transaction: done
        
        $ conda list tensorflow
        # packages in environment at /home/ubuntu/anaconda2/envs/ai:
        #
        # Name                    Version                   Build  Channel
        tensorflow                2.2.0           mkl_py36h5a57954_0  
        tensorflow-base           2.2.0           mkl_py36hd506778_0  
        tensorflow-datasets       1.2.0                    py36_0    anaconda
        tensorflow-estimator      2.2.0              pyh95af2a2_0    conda-forge
        tensorflow-metadata       0.14.0             pyhe6710b0_1  
        
        
        

        【讨论】:

          【解决方案5】:

          很遗憾,截至 2021 年 4 月,没有任何解决方案适合我。

          有几个.condarc 文件需要编辑,以确保所需的频道优先级:

          1. ~/.condac。在这里,您会发现“全局”频道被添加到手动添加的所有其他频道(例如default 频道或conda-forge 在我的情况下以某种方式到达这里,即使我没有手动添加它)。通过命令行界面更改/添加其他频道不会取代此处列出的频道的最高优先级

          2. .condarc anaconda 根目录中的文件。这是手动添加的频道结束的地方(我还会检查~/anaconda3/envs/{env_names}/ 以获取特定于环境的.condarc 文件)。

          如果您想完全控制通道优先级:

          1. ~/.condarc 文件中的清理频道部分(顶部)。
          2. 根据所需的通道优先级手动编辑.condarc 文件,每个环境(包括基础)一个文件
          3. 将通道优先级设置为truestrict
          4. 使用conda config --show channels检查您的编辑结果

          【讨论】:

            【解决方案6】:

            您可以按如下方式更改频道优先级:

            1. conda 配置 --get 这将列出从最低到最高优先级的所有频道
            2. 使用添加频道 conda config --add 频道 ---(你的频道) 您添加的最后一个频道获得最高优先级..所以保持顺序。即使您已经拥有频道,您也可以添加频道,以便更改优先顺序

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2012-10-08
              • 2010-11-06
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2019-04-21
              • 2015-03-10
              • 1970-01-01
              相关资源
              最近更新 更多