1 回滚
conda环境可以通过list命令查看当前conda环境有哪些版本,
conda list -h
可以看到使用方法:重点关注其中的-n和-r参数。
usage: conda list [-h] [-n ENVIRONMENT | -p PATH] [--json] [-v] [-q] [--show-channel-urls] [-c] [-f] [--explicit] [--md5] [-e] [-r] [--no-pip] [regex]
List linked packages in a conda environment.
Options:
positional arguments:
regex List only packages matching this regular expression.
optional arguments:
-h, --help Show this help message and exit.
--show-channel-urls Show channel urls. Overrides the value given by `conda config --show show_channel_urls`.
-c, --canonical Output canonical names of packages only. Implies --no-pip.
-f, --full-name Only search for full names, i.e., ^<regex>$.
--explicit List explicitly all installed conda packaged with URL (output may be used by conda create --file).
--md5 Add MD5 hashsum when using --explicit
-e, --export Output requirement string only (output may be used by conda create --file).
-r, --revisions List the revision history and exit.
--no-pip Do not include pip-only installed packages.
Target Environment Specification:
-n ENVIRONMENT, --name ENVIRONMENT
Name of environment.
-p PATH, --prefix PATH
Full path to environment location (i.e. prefix).
Output, Prompt, and Flow Control Options:
--json Report all output as json. Suitable for using conda programmatically.
-v, --verbose Use once for info, twice for debug, three times for trace.
-q, --quiet Do not display progress bar.
Examples:
List all packages in the current environment:
conda list
List all packages installed into the environment 'myenv':
conda list -n myenv
Save packages for future use:
conda list --export > package-list.txt
Reinstall packages from an export file:
conda create -n myenv --file package-list.txt
然后我们可以使用如下命令
conda list -n yolov5-lh -r
可以看到当前的conda环境有两个版本
然后可以使用如下命令回退到之前的版本
conda install --revision 0
2 复制和迁移
复制有好几种方法,我这里是直接cp命令把ens路径下的整个文件复制一份,我们创建的每个conda环境在/root/anaconda3/envs/路径下都会有个文件夹,
复制就直接
cp -drf /root/anaconda3/envs/yolov5_chw /root/anaconda3/envs/yolov5_chw_new
然后就可以用下面的命令激活新的环境。
conda activate yolov5_chw_new
同理,如果我们想把某个服务器的conda环境迁移到另一个服务器中,也可以直接把这个包复制到另一台服务器中。