7. Conda Environment

For the python example, we are using Anaconda environment to manage our python packages.

See this guide for details on how to create a shared conda environment. For this class, a shared conda environment was created in /zfs/gsb/intermediate-yens/conda/ocr directory and we can all use the path to that conda environment. Later, we will make this conda environment a kernel in JupyterHub.

Load anaconda module:

$ ml anaconda3

Then, activate the shared conda environment. This adds the python path to our current session so the python we are using is the new conda environment’s python:

$ source activate /zfs/gsb/intermediate-yens/conda/ocr

Check that the python binary is inside the newly created conda environment:

$ which python

Check that the version of python is 3.10:

$ python --version
Python 3.10.6

List available conda environments (you should see base and any other environments you have):

$ conda info -e

Note that this will not list shared environments you did not create.

You should see at least a base conda environment:

# conda environments:
                      *  /zfs/gsb/intermediate-yens/conda/ocr
base                     /software/free/anaconda/2022.05

The default conda environment is base (after loading anaconda module but not activating any environment) and the active conda environment is indicated with *.

We already installed the necessary python packages. List the python packages in the active conda environment:

$ pip list

You should see:

Package                       Version
----------------------------- ---------
asttokens                     2.1.0
async-generator               1.10
backcall                      0.2.0
backports.functools-lru-cache 1.6.4
certifi                       2022.9.14
contourpy                     1.0.6
cycler                        0.11.0
debugpy                       1.6.3
decorator                     5.1.1
entrypoints                   0.4
executing                     1.2.0
fonttools                     4.38.0
h11                           0.13.0
ipykernel                     6.17.0
ipython                       8.6.0
jedi                          0.18.1
jupyter_client                7.4.4
jupyter_core                  4.11.2
kiwisolver                    1.4.4
matplotlib                    3.6.2
matplotlib-inline             0.1.6
nest-asyncio                  1.5.6
numpy                         1.23.4
outcome                       1.2.0
packaging                     21.3
pandas                        1.5.1
parso                         0.8.3
pexpect                       4.8.0
pickleshare                   0.7.5
Pillow                        9.3.0
pip                           22.3.1
prompt-toolkit                3.0.32
psutil                        5.9.4
ptyprocess                    0.7.0
pure-eval                     0.2.2
Pygments                      2.13.0
pyparsing                     3.0.9
PySocks                       1.7.1
pytesseract                   0.3.10
python-dateutil               2.8.2
pytz                          2022.6
pyzmq                         24.0.1
selenium                      4.4.3
setuptools                    65.5.1
six                           1.16.0
sniffio                       1.3.0
sortedcontainers              2.4.0
stack-data                    0.6.0
tornado                       6.2
tqdm                          4.64.1
traitlets                     5.5.0
trio                          0.21.0
trio-websocket                0.9.2
visidata                      2.10.1
wcwidth                       0.2.5
wheel                         0.38.2
wsproto                       1.2.0

Now to run our python script, all we have to do is load anaconda module and activate the conda environment before running the python program.