Conda is a package manager and environment management system for the Python programming language. I generally recommend using a minimal version called Miniconda, described below.
Linux
To install Miniconda on a Linux machine, run the following:
When asked if you wish to add conda to your PATH environment variable and/or to run conda init after completion, enter yes. Ignore the warning.
Mac/Windows
For Mac/Windows, you should download and execute the Miniconda installer found here. You should select the option to add conda to your PATH environment variable. Ignore the warning.
Making a Conda Environment
Once that's done, we will create and activate an environment called quacc and install some packages.
conda create --name quacc python=3.11
conda activate quacc
conda install pip
pip install uv
uv pip install quacc jupyter
It is generally best to keep your base conda environment clean and to rely on other environments instead for installing new packages. It is often wise to make a conda environment for each project as a matter of reproducibility and ease of use.
Every now and then, you should run conda clean --all to remove the cached installers that end up accumulating a lot of space.
Nuking a Conda Environment
More often than one would like, you'll need to destroy your conda environment and start fresh if things just get messy. To do that:
conda env remove --name quacc
Then re-make your Conda environment like before.
Installation on the Clusters
While there are Anaconda modules on the individual clusters, it is recommended that you build your own for maximum flexibility.
Prineton HPC
The setup process can be streamlined on the Princeton HPC clusters as follows. Make sure to replace <NetID> in the first line below.
For internal consistency in the group, all publicly accessible Python code (and codes we work on collaboratively) should be formatted with ruff. Ruff is by no means a "perfect" formatter (which is largely a matter of preference). However, there are few things more frustrating in scientific computing than dealing with formatting inconsistencies when you're just trying to get things done. Ruff is fast, uncompromising, and "just works."
To format your code with Ruff, make sure it is installed (e.g. pip install ruff). To format code from the command line, run ruff format in the directory of files you want to format. Use ruff check --fix to apply common lint fixes. VS Code will also do this automatically on-save if you have the Ruff extension installed.
Jupyter Notebooks
Looking for a tutorial on how to use Jupyter Notebooks? See a written setup tutorial here and a video walkthrough here.
To use Jupyter Notebooks on the Princeton HPC clusters, refer to this guide.
Jupyter Notebooks are a great way to do exploratory data analysis, preparing small scripts, launch workflows on the HPC cluster, and write up tutorials. That said, Jupyter Notebooks are rarely ideal for writing research code. Most programming efforts should be with their own dedicated Python package that you use in editable mode (pip install -e .). Jupyter Notebooks make it difficult to adopt good programing practices, like modularity and testing. This isn't to say that you should avoid Jupyter Notebooks, but as they say: with great power comes great responsibility.
If you are looking for a more interactive experience, check out Marimo notebooks. Marimo notebook are ideal for presentations and demos.