私有包#

注意

包含私有包的个人付费计划是 Anaconda.org 提供的旧版服务,现已不再提供。但是,过去拥有私有包的任何人仍然可以私有托管这些包。

使包私有化#

默认情况下,所有上传到 Anaconda.org 的包都可供任何有权访问仓库的人访问。

注意

截至 2023 年 8 月 30 日,只有付费计划用户才能将其包标记为私有。

要将上传到您在 Anaconda.org 上的用户通道的包标记为私有

  1. 选择所需的包。

  2. 导航到设置选项卡。

  3. 在侧边栏中选择管理员

  4. 选择私有

注意

其他 Anaconda.org 用户可以使用令牌或登录来访问您的私有包。

使用令牌访问私有包#

令牌是一个随机字母数字字符串,用于限制和提供对通道上包的访问权限。

要使您的私有包可以通过令牌访问,请创建一个访问令牌,其中包含 Anaconda Client 的以下范围

conda:download

或者,在 anaconda.org 上进行调整:在访问设置中,选择允许从 conda 仓库进行私有下载

使用令牌访问私有包#

如果您打算从私有通道安装许多包,您可以将该通道包含在您的 .condarc 文件中。这将在您在该通道上搜索包时包含令牌。要从 Anaconda Prompt(macOS/Linux 终端)将用户通道添加到您的 .condarc 文件,请运行以下命令

# Replace <TOKEN> with the provided token
# Replace <CHANNEL> with a user channel
conda config --add channels https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>

您也可以使用令牌来安装包,而无需先将通道添加到您的 .condarc 文件中,方法是使用通道的完整 URL。在 Anaconda Prompt(macOS/Linux 终端)中,运行以下命令

# Replace <TOKEN> with the provided token
# Replace <CHANNEL> with a user channel
# Replace <PACKAGE> with the name of the package you want to install
conda install --channel https://conda.anaconda.org/t/<TOKEN>/<CHANNEL> <PACKAGE>

访问带有标签的私有包#

要使用令牌和标签名称从通道安装包

# Replace <TOKEN> with the provided token
# Replace <CHANNEL> with a user channel
# Replace <LABEL_NAME> with the label name
# Replace <PACKAGE> with the name of the package you want to install
conda install --channel https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>/label/<LABEL_NAME> <PACKAGE>

使用令牌访问私有 PyPI 包#

  1. 也可以在 Web UI 中安装私有 PyPI 包

    # Replace <TOKEN> with the provided token
    # Replace <CHANNEL> with a user channel
    https://pypi.anaconda.org/t/<TOKEN>/<CHANNEL>
    

以注册用户身份访问私有包#

要使您的私有包可供已登录的用户使用

  1. 创建一个组织

  2. 在该组织中创建一个组(可以是只读的)。

  3. 将所需用户添加到该组。

  4. 将包上传到该组织,或将现有包转移到该组织。

在您授予用户访问权限后,其他用户可以使用 Web UI 或 Anaconda Client 安装您的包。

要安装包

  1. 在浏览器中,导航到所需的通道。

  2. 打开 Anaconda Prompt(macOS/Linux 终端)并运行以下命令

    # Replace <ORGANIZATION> with the organization name
    # Replace <PACKAGE> with the package name
    conda install anaconda-client
    anaconda login
    conda install --channel https://conda.anaconda.org/<ORGANIZATION> <PACKAGE>