打包环境总结
1.激活需要复制的虚拟环境
conda env list
cd /home/ww/miniconda3/envs/
conda activate webtool
2.将虚拟环境打包,包名:webtool_test.tar.gz
conda pack -n webtool -o webtool_test.tar.gz
3.创建虚拟环境文件夹,把打包的虚拟环境放到该文件夹下
mkdir -p webtool_testtar -xzf /home/ww/Desktop/test_env/webtool/webtool_test.tar.gz -C /home/ww/miniconda3/envs/webtool_test/
4.激活虚拟环境
conda env list
conda activate webtool_test
5.直接启动项目,可以验证虚拟环境是否迁移成功
sh run.sh
环境打包详细步骤
要打包环境,请执行以下操作:To install the environment:
Pack environment my_env into my_env.tar.gz
$ conda pack -n my_env
Pack environment my_env into out_name.tar.gz
$ conda pack -n my_env -o out_name.tar.gz
Pack environment located at an explicit path into my_env.tar.gz
$ conda pack -p /explicit/path/to/my_env
To install the environment:
要安装环境,请执行以下操作:
Unpack environment into directory my_env
$ mkdir -p my_env
$ tar -xzf my_env.tar.gz -C my_env
Use Python without activating or fixing the prefixes. Most Python
libraries will work fine, but things that require prefix cleanups
will fail.
$ ./my_env/bin/python
Activate the environment. This adds my_env/bin
to your path
$ source my_env/bin/activate
Run Python from in the environment
(my_env) $ python