私有包#
注意
带有私有套餐的个人付费计划是 Anaconda.org 的旧版产品,现已不再可用。但是,过去拥有私有包的任何人仍然可以私下托管这些包。
将包设为私有#
默认情况下,任何有权访问仓库的人都可以访问上传到 Anaconda.org 的所有包。
注意
自 2023 年 8 月 30 日起,只有使用付费计划的用户才能将其程序包标记为私有。
要将上传到 Anaconda.org 上的用户频道的包标记为私有:
选择所需的包。
导航到 设置 选项卡。
在侧边栏中选择 管理员。
选择 Private(私有)。
注意
其他 Anaconda.org 用户可以使用Token或通过登录来访问您的私有程序包。
使用Token访问私有包#
Token是一个随机的字母数字字符串,用于限制和提供对通道上包的访问。
要使您的私有包可通过Token访问,请为 Anaconda Client 创建一个访问Token,其中包括以下范围:
conda:download
或者,对 anaconda.org 进行调整:在访问设置中,选择 Allow private downloads from conda repositories(允许从 conda 存储库进行私有下载)。
使用 Token 访问私有软件包#
如果您打算从专用频道安装多个软件包,则可以将该频道包含在.condarc
文件。这将包括您在该频道上搜索 package 时获得的Token。要将用户频道添加到.condarc
文件从 Anaconda Prompt(macOS/Linux 上的终端)运行以下命令:
# Replace <TOKEN> with the provided token
# Replace <CHANNEL> with a user channel
conda config --add channels https://conda.anaconda.org/t/<TOKEN>/<CHANNEL>
您还可以使用Token安装软件包,而无需先将频道添加到您的.condarc
文件。在 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>
访问具有标签的私有包#
要使用Token和标签名称从通道安装包,请执行以下作:
# 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>
使用Token访问私有 PyPI 包#
私有 PyPI 包也可以安装在 Web UI 中:
# Replace <TOKEN> with the provided token # Replace <CHANNEL> with a user channel https://pypi.anaconda.org/t/<TOKEN>/<CHANNEL>
以注册用户身份访问私有软件包#
要向已登录的用户提供您的私有包,请执行以下作:
创建组织。
在该组织中创建一个组(可以是只读的)。
将所需的用户添加到组。
将包上传到组织,或将现有包转移到组织。
授予用户访问权限后,其他用户可以使用 Web UI 或 Anaconda Client 安装您的软件包。
要安装软件包:
在浏览器中,导航到所需的渠道。
打开 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>