conda @config command @package cache package cache shared @Channels @conda install pyside6@channel_alias

Article directory

    • refs
    • check basic information
      • config add pkgs_dirs
      • View the condarc source file
      • query by field
      • all information
    • conda Channel
      • conda-forge channel install package@conda install cupy
      • Error caused by inappropriate url Channel
    • Channel specifies to use the complete url link conda install@conda to temporarily change the source
      • conda install install pyside6
      • Domestic Channel installation
      • conda default source installation
    • default_channels
    • Channel alias@Set a channel alias (channel_alias)
      • Check the default channel_alias value
      • examples:
      • Set channel_alias to own repository

refs

  • Configuring a shared package cache – Anaconda documentation
  • conda config – conda 23.3.0.post2+8419c02f5 documentation

Check basic information

  • (d:\condaPythonEnvs\d2l) PS D:\repos\blogs> conda info
    
         active environment: d2l
        active env location : d:\condaPythonEnvs\d2l
                shell level: 1
           user config file: C:\Users\cxxu\.condarc
     populated config files: C:\Users\cxxu\.condarc
              conda version: 23.1.0
        conda-build version : not installed
             python version: 3.9.5.final.0
           virtual packages: __archspec=1=x86_64
                              __cuda=12.0=0
                              __win=0=0
           base environment: C:\Users\cxxu\miniconda3 (writable)
          conda av data dir : C:\Users\cxxu\miniconda3\etc\conda
      conda av metadata url : None
               channel URLs: https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
                              https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                              https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/win-64
                              https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                              https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/win-64
                              https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
              package cache: C:\Users\cxxu\miniconda3\pkgs
                              C:\Users\cxxu\.conda\pkgs
                              C:\Users\cxxu\AppData\Local\conda\conda\pkgs
           envs directories : d:\condaPythonEnvs
                              C:\Users\cxxu\miniconda3\envs
                              C:\Users\cxxu\.conda\envs
                              C:\Users\cxxu\AppData\Local\conda\conda\envs
                   platform : win-64
                 user-agent : conda/23.1.0 requests/2.28.1 CPython/3.9.5 Windows/10 Windows/10.0.22621
              administrator : False
                 netrc file : None
               offline mode : False
    
  • By default, package chace contains 3 directories:

    • package cache: C:\Users\cxxu\miniconda3\pkgs
                        C:\Users\cxxu\.conda\pkgs
                        C:\Users\cxxu\AppData\Local\conda\conda\pkgs
      

config add pkgs_dirs

  • Use config --add pkgs_dirs to add directories to pkgs_dirs

    • If you only add one or two, you can use the command line to add:

    • (d:\condaPythonEnvs\d2l) PS D:\conda3\pkgs> conda config --add pkgs_dirs d:\conda3\pkgs
      Warning: 'd:\conda3\pkgs' already in 'pkgs_dirs' list, moving to the top
      
    • If the added item has been added before, the order of the item will be adjusted (moving to the top)

  • If you need to add multiple directories, you can open (create without) the condarc file and edit it directly

  • After editing, check the following:

  • (d:\condaPythonEnvs\d2l) PS D:\conda3\pkgs> conda info
    
         active environment: d2l
        active env location : d:\condaPythonEnvs\d2l
                shell level: 1
           user config file: C:\Users\cxxu\.condarc
    ...
              package cache: d:\conda3\pkgs
                              C:\Users\cxxu\AppData\Local\conda\conda\pkgs
                              C:\Users\cxxu\.conda\pkgs
                              C:\Users\cxxu\miniconda3\pkgs
           envs directories : d:\condaPythonEnvs
                              C:\Users\cxxu\miniconda3\envs
                              C:\Users\cxxu\.conda\envs
                              C:\Users\cxxu\AppData\Local\conda\conda\envs
                   platform : win-64
                 user-agent : conda/23.1.0 requests/2.28.1 CPython/3.9.5 Windows/10 Windows/10.0.22621
              administrator : False
                 netrc file : None
               offline mode : False
    

View condarc source file

  • conda config --show-sources

Query by field

  • If you want to query the content configured in the condarc file, you can use the command line to query conda config --get

    • (d:\condaPythonEnvs\pt2.0) PS D:\repos\CCSER\d2l-zh\pytorch> conda config --get pkgs_dirs
      --add pkgs_dirs 'C:\Users\cxxu\miniconda3\pkgs'
      --add pkgs_dirs 'C:\Users\cxxu\.conda\pkgs'
      --add pkgs_dirs 'C:\Users\cxxu\AppData\Local\conda\conda\pkgs'
      --add pkgs_dirs 'd:\conda3\pkgs'
      (d:\condaPythonEnvs\pt2.0) PS D:\repos\CCSER\d2l-zh\pytorch>
      

All information

  • conda config --show can query more abundant information (including the default configuration and not displaying the information set in the condarc file)

Conda Channel

  • Conda channels – conda 23.3.0.post2+8419c02f5 documentation

conda-forge channel install package@conda install cupy

  • The configuration provided by Tsinghuayuan, in which conda-forge can directly install some packages, such as cupy

    • (d:\condaPythonEnvs\pt2.0) PS D:\repos\blogs\python> conda install -c conda-forge cupy
      Collecting package metadata (current_repodata.json): done
      Solving environment: done
      
      ## Package Plan ##
      
        environment location: d:\condaPythonEnvs\pt2.0
      
        added / updated specs:
          - cupy
      
      
      The following packages will be downloaded:
      
          package |
          --------------------------|-----------------
          cudatoolkit-11.1.1 | heb2d755_10 1.20 GB conda-forge
          cupy-11.6.0 | py310h1011f98_0 49.0 MB conda-forge
          fastrlock-0.8 | py310h8a704f9_2 29 KB conda-forge
          python_abi-3.10 | 2_cp310 4 KB conda-forge
          -------------------------------------------------- ----------
                                                 Total: 1.25GB
      
      The following NEW packages will be INSTALLED:
      
        cudatoolkit conda-forge/win-64::cudatoolkit-11.1.1-heb2d755_10
        cupy conda-forge/win-64::cupy-11.6.0-py310h1011f98_0
        fastrlock conda-forge/win-64::fastrlock-0.8-py310h8a704f9_2
        python_abi conda-forge/win-64::python_abi-3.10-2_cp310
      
      The following packages will be SUPERSEDED by a higher-priority channel:
      
        ca-certificates anaconda/pkgs/main::ca-certificates-2~ --> conda-forge::ca-certificates-2022.12.7-h5b45459_0
        certifi anaconda/pkgs/main/win-64::certifi-20~ --> conda-forge/noarch::certifi-2022.12.7-pyhd8ed1ab_0
      
      
      Proceed ([y]/n)? n
      

Error caused by inappropriate url Channel

  • So I tried to use -c url to specify the channel. Unexpectedly, Tsinghua source and Ali source both prompted: UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel anaconda/cloud...

  • It was later discovered that the problem was that the url was incomplete

    • conda search -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/ pyside6
      conda search -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge pyside6
      
    • The first statement suffix conda-forge is missing, although you can open the page through a browser, but it cannot be used for conda -c parameters

Channel specifies to use the complete url link conda install@conda to temporarily change the source

conda install install pyside6

  • Suppose your source (channel) replaces the domestic source

    • Taking Tsinghuayuan as an example, using conda install pyside6 and conda install -c conda-forge pyside6 will most likely fail to download
  • Check if pyside6 is available on the current conda-forge Channel

    • PS C:\Users\cxxu\Desktop> conda search -c conda-forge pyside6
      Loading channels: done
      # Name Version Build Channel
      pyside6 6.4.0 py310h7a8ee39_0 conda-forge
      pyside6 6.4.0 py310h7a8ee39_1 conda-forge
      pyside6 6.4.0 py310h7a8ee39_2 conda-forge
      pyside6 6.4.0 py310h7a8ee39_3 conda-forge
      
    • At this time, I use the Channel configuration of Tsinghua source. Although I found that there are related packages through conda search -c conda-forge pyside6, when I installed it, it stayed at solving environment... this step

  • I guess there should be some problems with the configuration method provided by domestic sources

    • Check the documentation of conda channel_alias and find that conda-forge is an abbreviation, and a prefix url will be inserted when executing
    • You can check by conda config --show
    • Later, we will summarize and continue to discuss the channel_alias field

Domestic Channel Installation

  • conda search -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge pyside6

  • Find out if a related package is provided

    • PS D:\repos\blogs\python> conda search -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge pyside6
      Loading channels: done
      # Name Version Build Channel
      pyside6 6.4.0 py310h7a8ee39_0 anaconda/cloud/conda-forge
      pyside6 6.4.0 py310h7a8ee39_1 anaconda/cloud/conda-forge
      pyside6 6.4.0 py310h7a8ee39_2 anaconda/cloud/conda-forge
      pyside6 6.4.0 py310h7a8ee39_3 anaconda/cloud/conda-forge
      
  • Install

    • PS D:\repos\blogs\python> conda activate pyside_conda
      (d:\condaPythonEnvs\pyside_conda) PS D:\repos\blogs\python> conda install -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge pyside6
      
      Collecting package metadata (current_repodata.json): done
      Solving environment: done
      
      ## Package Plan ##
      
        environment location: d:\condaPythonEnvs\pyside_conda
      
        added / updated specs:
          -pyside6
      
      
      The following packages will be downloaded:
      
          package |
          --------------------------|-----------------
          bzip2-1.0.8 | h8ffe710_4 149 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          cairo-1.16.0 | hd694305_1014 2.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          double-conversion-3.2.0 | h63175ca_1 72 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          expat-2.5.0 | h1537add_0 339 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          font-ttf-dejavu-sans-mono-2.37| hab24e00_0 388 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
      ...
      
      https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          vs2015_runtime-14.34.31931 | h4c5c07a_10 708 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          wheel-0.40.0 | pyhd8ed1ab_0 54 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          xz-5.2.6 | h8d14728_0 213 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          zlib-1.2.13 | hcfcfb64_4 113 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          zstd-1.5.2 | h12be248_6 282 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
          -------------------------------------------------- ----------
                                                 Total: 159.7MB
      
      The following NEW packages will be INSTALLED:
      
        bzip2 anaconda/cloud/conda-forge/win-64::bzip2-1.0.8-h8ffe710_4
        ca-certificates anaconda/cloud/conda-forge/win-64::ca-certificates-2022.12.7-h5b45459_0
        cairo anaconda/cloud/conda-forge/win-64::cairo-1.16.0-hd694305_1014
        ...
        xz anaconda/cloud/conda-forge/win-64::xz-5.2.6-h8d14728_0
        zlib anaconda/cloud/conda-forge/win-64::zlib-1.2.13-hcfcfb64_4
        zstd anaconda/cloud/conda-forge/win-64::zstd-1.5.2-h12be248_6
      
      
      Proceed ([y]/n)? y
      
      
      Downloading and Extracting Packages
      
      Preparing transaction: done
      Verifying transaction: done
      Executing transaction: done
      (d:\condaPythonEnvs\pyside_conda) PS D:\repos\blogs\python>
      

conda default source installation

  • I try again with conda’s default sources:

    • https://conda.anaconda.org/conda-forge/

    • The complete command is conda install -c https://conda.anaconda.org/conda-forge/pyside6

    • (d:\condaPythonEnvs\pt2.0) PS D:\repos\blogs\python> conda install -c https://conda.anaconda.org/conda-forge/pyside6
      Collecting package me-data (current_repodata.json): done
      Solving environment: done
      
      ## Package Plan ##
      
        environment location: d:\condaPythonEnvs\pt2.0
      
        added / updated specs:
          -pyside6
      
      
      The following packages will be downloaded:
      
          package |
          --------------------------|-----------------
          cairo-1.16.0 | hd694305_1014 2.3 MB conda-forge
          double-conversion-3.2.0 | h63175ca_1 72 KB conda-forge
          expat-2.5.0 | h1537add_0 339 KB conda-forge
          font-ttf-dejavu-sans-mono-2.37| hab24e00_0 388 KB conda-forge
          font-ttf-inconsolata-3.000 | h77eed37_0 94 KB conda-forge
          font-ttf-source-code-pro-2.038| h77eed37_0 684 KB conda-forge
          font-ttf-ubuntu-0.83 | hab24e00_0 1.9 MB conda-forge
          fontconfig-2.14.2 | hbde0cde_0 186 KB conda-forge
          ...
      
    • The official source, predictably, is quite slow

default_channels

  • Using the .condarc conda configuration file – conda 23.3.0.post2+8419c02f5 documentation

  • Setting method (command line method)

    • Take Tsinghuayuan in China as an example:

    •  conda config --set channel_alias https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
      
  • Check: conda config --show channel_alias

    • PS C:\Users\cxxu\Desktop> conda config --show channel_alias
      channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      

Channel alias@Set a channel alias (channel_alias)

  • Using the .condarc conda configuration file – conda 23.3.0.post2+8419c02f5 documentation
  • Whenever you use the -c or –channel flags to give conda a channel name that is not a URL, conda will add the channel_alias prefix to the name it is given. The default channel_alias is https://conda.anaconda.org.
  • If the channel_alias is set to https://my.anaconda.repo:8080/conda/, then users who run the command conda install -c conda-forge some-package will download from https:// my.anaconda.repo:8080/conda/conda-forge Install package some-package.

Check the default channel_alias value

  • Take powershell as an example: conda config --show |sls channel_alias

    PS C:\Users\cxxu\Desktop> conda config --show |sls channel_alias
    
    channel_alias: https://conda.anaconda.org
    migrated_channel_aliases: []
    
  • If not set, the default value is https://conda.anaconda.org

examples:

  • For example, the command:

    conda install --channel asmeurer is the same as the following command:

    conda install --channel https://conda.anaconda.org/asmeurer

Set channel_alias to your own repository

  • For example: set channel_alias to the repository of https://your.repo/: channel_alias: https://your.repo/

  • On Windows, you must include a slash (“/”) at the end of the URL:

    • For example: https://your.repo/conda/
  • When channel_alias is set to a repository at https://your.repo.com:

    • conda install --channel jsmith is the same as the following command:
    • conda install --channel https://your.repo.com/jsmith