有时候需要在离线环境下更新python依赖库版本,这时可以用conda迁移.
步骤:
- 复制要克隆的conda环境到离线主机中;
- 复制pkgs目录到离线主机中;
- 创建克隆环境;
补充说明:
conda安装目录"~/anaconda3"与"~/.conda"配置是通用的,如"~/anaconda3/envs"与"~/.conda/envs","~/anaconda3/pkgs"与"~/.conda/pkgs"都会生效;在复制的时候需要根据时间等条件去判断那个才是最终的
(1)
如克隆py37环境,"scp -r ~/.conda/envs/py37 用户@ip:临时路径/"
(2)
"scp -r ~/.conda/pkgs 用户@ip:~/.conda"
(3)
"conda create -n py37 --clone 临时路径/py37 --offline"
如出现一下类型错误如"_openmp_mutex",在"~/.conda/pkgs"目录中,通过删除对应文件后重新解压.
conda create -n py37 --clone ./py37 --offline
Preparing transaction: done
Verifying transaction: failed
CondaVerificationError: The package for _openmp_mutex located at ~/.conda/pkgs/_openmp_mutex-4.5-1_gnu
appears to be corrupted. The path 'lib/libgomp.so.1'
specified in the package manifest cannot be found.
CondaVerificationError: The package for python located at ~/.conda/pkgs/python-3.7.10-h12debd9_4
appears to be corrupted. The path 'compiler_compat/ld'
specified in the package manifest cannot be found.
ClobberError: The package 'https://mirrors.ustc.edu.cn/anaconda/pkgs/main::ncurses-6.2-he6710b0_1' cannot be installed due to a
path collision for 'lib/terminfo'.
This path already exists in the target prefix, and it won't be removed
by an uninstall action in this transaction. The path is one that conda
doesn't recognize. It may have been created by another package manager.