Skip to content

Commit c44679d

Browse files
Merge pull request #38 from TheJacksonLaboratory/clarify_conda
Update conda.md to clarify commands and link to cheatsheet
2 parents a970b31 + 54cb327 commit c44679d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

conda.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
## Installing conda, *if you don't have it already*
1515

16+
(Note: I encourage using `conda` version no older than 23.10.)
17+
1618
1. There are several distributions of `conda` and it can pull packages from many different sources
1719
called "channels". In this workshop we will use the [conda-forge](https://conda-forge.org) distribution called "miniforge" (or "miniforge3").
1820
- Go to the conda-forge downloads page:
@@ -41,7 +43,7 @@
4143
Type:
4244

4345
```bash
44-
conda env create -n bestpractices
46+
conda create -n bestpractices
4547
```
4648

4749
This will create a new environment named "bestpractices" (`-n` is shorthand for `--name`).
@@ -66,15 +68,15 @@
6668
And then, to delete the environment use:
6769
6870
```bash
69-
conda env remove -n bestpractices
71+
conda remove -n bestpractices --all
7072
```
7173
7274
Try running `conda env list` and you will see you have no environments other than `base`.
7375
7476
6. Now let's try to create an environment *with* Python. Type:
7577

7678
```bash
77-
conda env create -n bestpractices python=3.13
79+
conda create -n bestpractices python=3.13
7880
```
7981
(or pick a version of your choice). Activate your new environment as before and try:
8082

@@ -123,7 +125,7 @@
123125
conda env create -f environment.yml
124126
```
125127
This will create a new environment named `bestpractices_final` with
126-
all the packages specified in the *environment.yml* file.
128+
all the packages specified in the *environment.yml* file (`-f` is shorthand for `--file`).
127129
Activating the new environment as before, using `conda activate bestpractices_final` (why is this the name?) and try running `python --version`. Try running `conda list` to see all the installed
128130
packages. Everything listed in the `environment.yml` should be there, along with all
129131
dependencies.
@@ -134,7 +136,7 @@
134136
```
135137
This will install all packages listed in a `requirements.txt` file from PyPI.
136138
137-
6. A final tip: append `--dry-run` to your `conda` commands to see what they will do without actually making any changes.
139+
6. A final tip: append `--dry-run` to your `conda` commands to see what they will do without actually making any changes and refer to the [`conda` commands cheatsheet](https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html#cheatsheet) if you're unsure about how to accomplish something.
138140

139141
## Some advice on projects and dependencies
140142

@@ -145,4 +147,4 @@ Beyond using virtual environments, here are some best practices when it comes to
145147
- For *portability* and ability to incorporate your code into other projects, avoid pinning versions strictly: pin to the minimum version required for the functionality you need.
146148
- In addition to your environment file, for maximal reproducibility, consider generating **a lock file**, which specifies the *exact versions of all packages and their dependencies* in your environment. This can be done with `conda` using [conda-lock](https://github.com/conda/conda-lock) or with `pip` using [pip-tools](https://github.com/jazzband/pip-tools/). (Additionally, both `uv` and `pixi` automatically generate lock files.)
147149
- If you will be sharing your code or expect others to run it, consider making a Python package. Check out the [pyOpenSci Python Package Guide](https://www.pyopensci.org/python-package-guide/index.html) for more details on how to do that!
148-
150+

0 commit comments

Comments
 (0)