使用 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 包安装到 root conda 环境中很重要,而不是 root 用户。以下命令可确保发生这种情况:

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)系统上创建。