Change the Installation Location for Anaconda Environments
Anaconda environments tend to be large. If you initially install one in a system directory, you may eventually run out of space. In that case, you can move the entire environment directory. There are two common approaches: moving the files directly or reinstalling the environment.
1. On the same machine: Move the environment files directly
On the same machine, the simplest approach is to move the environment directory to the new location and then create a symbolic link.
For example, on my Ubuntu system, Anaconda was originally installed at /home/liuxiao/anaconda3/. To move it to /data/anaconda3/, I can follow these steps:
1) Move the directory using the mv command:
sudo mv /home/liuxiao/anaconda3/ /data/anaconda3/
2) Create a symbolic link at the original path:
sudo ln -s /data/anaconda3/ /home/liuxiao/anaconda3/
2. Export the environment file and reinstall
If you’re moving to a different machine or run into other issues, you can follow the method recommended on the official website: export the environment to a file and use it to reinstall the environment. Here’s how:
1) Export the environment file on the original machine:
conda env export > environment.yml
2) Reinstall the environment on the new machine (note that the Anaconda versions may need to match):
conda env create -f environment.yml
References
[1] https://blog.csdn.net/weixin_33127753/article/details/104620211
[2] https://blog.perillaroc.wang/post/2020/2020-07-22-move-anaconda-into-a-new-directory/