Info
It is highly recommended to use venv first, as it is much faster than conda. However, some Python packages depend on non-Python packages, e.g.
boost
, then install using conda is still a better way.
Create an environment using a machine with Internet
conda create -n matsci python numpy scipy matplotlib seaborn pandas pymatgen phonopy ase pytables scikit-learn numba glob2 jupyter -c conda-forge
Here, I take the environment name as matsci
. You can put any packages that you need here. Here I used python numpy scipy matplotlib seaborn pandas pymatgen phonopy pytables
and ase
. Version can also be specified, e.g. python=3.7
Pack the whole environment
Sometimes, you need to use python package on a machine without internet connection. In these situations, you can first create a conda environment on a machine with internet, then use conda-pack
to pack the whole environment. Finally, you can use scp
or rsync
to upload it to the machine without internet and use it.
Install conda pack
conda install -c conda-forge conda-pack
Pack environment
conda pack -n matsci -o matsci.tar.gz
Restore environment on a remote machine without Internet
Deactivate the Anaconda environment on remote machine
conda deactivate
Upload the environment to the remote machine
scp matsci.tar.gz USER@REMOTE_MACHINE:CONDA_ENV_DIR
Donβt forget the β:β
Unzip the packed environment
tar -xvf matsci.tar.gz
Strongly recommended to unzip it in a folder
Activate the new environment
source CONDA_ENV_DIR/bin/activate
You can also use it in your submission jobs, just put the line above in your submission script
Comments
This method only works if the local machine and remote machine have the same platform, e.g. linux_x86_x64.
On fornax, you can first install on orion.