使用 cas-installer#
cas-installer 工具可以生成一个环境安装程序,这是一个可以在任何机器上运行的 bash 脚本或 Windows 可执行文件,用于在该机器上安装 conda 环境及其软件包的精确副本。
安装 cas-installer#
安装cas-installer需要来自Anaconda的令牌,当您的组织购买Repository、Workgroup或Enterprise时,您应该已经收到了该令牌。如果您无法再访问您的令牌,请提交支持票或通过企业支持联系我们。您也可以通过销售代表提供的电子邮件地址发送电子邮件给支持团队。
当你有了令牌后,运行:
export TOKEN=<your_anaconda_cloud-token>
conda config --add channels https://conda.anaconda.org/t/$TOKEN/anaconda-server
因为此工具允许您为conda环境创建安装程序,所以重要的是将cas-installer包安装到根conda环境中,而不是根用户。以下命令确保这一点:
conda install -n root cas-installer=1.3.2
使用 cas-installer 命令#
安装完成后,cas-installer
命令可用:
cas-installer -h
该命令以安装程序规范文件作为其参数,该文件指定了安装程序的名称、从中拉取包的conda通道、安装程序中包含的conda包等。
示例:
# ----------------- required -----------------
# name
name: test
# channels to pull packages from
# The &channels creates a back reference so that it can be reused as
# *channels in the conda_default_channels section below.
channels: &channels
- https://repo.anaconda.com/pkgs/free/
# specifications
specs:
- python
- grin
# ----------------- optional -----------------
# platform e.g. linux-32, osx-64, win-32 defaults to current platform
# platform: linux-64
# The conda default channels which are used when running a conda which
# was installed be the cas-installer created: requires conda---3.6.2 or
# greater---in the specifications. The *channels is a YAML reference to
# &channels above. It inserts all the channels from the channels key, so
# that they do not have to be typed twice.
conda_default_channels: *channels
# installer filename
# installer_filename: grin.sh
# default install prefix
default_prefix: /opt/anaconda
对于Windows,该工具创建基于nsis的.exe安装程序,这些安装程序只能在Windows平台上创建,尽管架构可能不同。对于Unix,该工具创建基于bash的.sh安装程序,这些安装程序只能在Unix——Linux或macOS——系统上创建。