TLDR:
the best method is below:
first, in old server
rsync -avr /home/xxxx/anaconda3/envs/your_env_name your_login_name@new_server_ip:/home/xxxx/miniconda3/envs/
then in new server conda activate your_env_name, and run pip list, you'll get error:
/bin/python: bad interpreter: No such file or directory: bad interpreter: No such file or directory
second, in new server
find ~/miniconda3/envs/nn/ -type f -exec grep --binary-files=without-match -rl "oldprefix" {} \; -exec sed -i 's+newprefix+g' {} +
the below replace all python prefix in envs dir, make commandline command like pip, work as expect.
--------------------------------separating line-----------------------------------
if you dont want to redownload packages in the new server (of same os platform), the official method is use pip install conda-pack
. conda-pack archives an entire environment including the package binaries, which is useful in low or no bandwidth situations.
Ab oberversation, by cat $(which pip)
you can find the pip command is just a linux file(with execute privilige assisiation to a python.exe path):
#!/home/your_home_name/miniconda3/envs/your_env_name/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
see the first line with #! shellbang, all python module command realized by entry_point such as pip, need to replace this python path prefix when move to new server.
AFAIK, what conda pack do is replace all prefix in old envs file form #!/home/your_home_name/miniconda3/envs/your_env_name/bin/python
to #!/usr/bin/python
, and conda unpack replace it to another path in your new server's conda directory
howerver with conda pack you need to tar.gzip first and rsync to new server, then untargzip.
the best method is below:
first, in old server
rsync -avr /home/xxxx/anaconda3/envs/your_env_name your_login_name@new_server_ip:/home/xxxx/miniconda3/envs/
then in new server conda activate your_env_name, and run pip list, you'll get error:
/bin/python: bad interpreter: No such file or directory: bad interpreter: No such file or directory
second, in new server
find ~/miniconda3/envs/nn/ -type f -exec grep --binary-files=without-match -rl "oldprefix" {} \; -exec sed -i 's+newprefix+g' {} +
the below replace all python prefix in envs dir, make commandline command like pip, work as expect.