==== Install Packages to Anaconda Python ==== For this example, we assume you have loaded the module '''anaconda3/2023.07''', and for that module you'll need to use a compute node in partition **centos7** (see [[cypress/using#Requestingpartitioncentos7withglibc2.17|here]]) {{{ idev --partition=centos7 module load anaconda3/2023.07 }}} 'conda' is the command to add packages to the Anaconda Python distribution. However, since you don't have permission in /share/apps/anaconda, it won't work. There is a workaround. Here, for example, we want to add 'mpi4py' Python wrapper library for MPI. You try: {{{ conda install mpi4py }}} But you will see an error message due to your lack of write permission to the shared directory, such as the following. {{{ EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: /share/apps/centos7/anaconda3/2023.07 uid: gid: }}} To avoid the above error, you'll have to clone the Python environment. By default, your conda environments are located in your home directory. But, we recommend that you use your group project directory. Setting the '''CONDA_ENVS_PATH''' environment variable will tell Anaconda where to place and look for your conda environments. For example: {{{ export CONDA_ENVS_PATH=/lustre/project/mygroup/myuser/conda-envs }}} will put your conda environments in the folder /lustre/project/mygroup/myuser/conda-envs (you may have to create this folder if it does not exist). By default, the package cache directory is created in your home directory, which will take up a large space as you use 'conda'. To change the package cache directory, edit ~/.condarc file and add {{{ pkgs_dirs: - /path/to/package_cache_directory }}} (If no ~/.condarc exists, try 'conda config'.) Then, you can create a new personal conda environment: {{{ conda create -n MPI python }}} 'MPI' is the name of the environment that you decide. Also, in general, in conda environments, Python should not use PYTHONPATH. (For more information, see [https://conda.io/projects/conda/en/latest/user-guide/troubleshooting.html#conda-reports-that-a-package-is-installed-but-it-appears-not-to-be here].) In particular, if you encounter errors during Python module import, then you should unset PYTHONPATH prior to activating your conda environment. Hence, {{{ source activate MPI }}} (When you get an error "!CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'", see [https://stackoverflow.com/questions/61915607/commandnotfounderror-your-shell-has-not-been-properly-configured-to-use-conda here]) Finally, you can install the package, {{{ conda install mpi4py }}} In case you encounter "Error: 'conda' can only be installed into the root environment", try {{{ conda remove conda-build conda remove conda-env conda install mpi4py }}} Next time, to use Anaconda Python with your environment, {{{ idev --partition=centos7 module load anaconda3/2023.07 export CONDA_ENVS_PATH=/lustre/project/mygroup/myuser/conda-envs source activate MPI }}} You have to state the above commands in your script when you run Python on batch jobs. ---- Example [https://wiki.hpc.tulane.edu/trac/wiki/cypress/Example%20VTK-python]