Loading Modules in a Jupyter Notebook
Interacting with the module system in Jupyter does not always work as expected. Common tactics like opening a shell and loading modules or using Jupyter's "bang" syntax to call a shell command
1 |
|
will not change Python's environment. Instead, you will need to interact with the module system more directly.
Configuration if Using Conda
Due to the way ICER's Conda/3
module works, you will need to make one small configuration change. Assuming you have set the CONDA3PATH
environment variable, from a command line, run the following code:
1 2 |
|
Loading modules in Python
Similarly to how the module system is made available to the bash shell, you can make the module system available in Python directly with an import statement. You will need to add the location of the module to your system path.
1 2 3 |
|
After this, the module
command can be used as a Python function:
1 2 |
|
Loading modules in Jupyter with jupyter-lmod
You can also integrate the module system directly in Jupyter using the jupyter-lmod
extension. You can install this on the command line into a virtual or Conda environment you are loading the Jupyter from with
1 |
|
Then, when you start the Jupyter notebook, you will have an extra tab on the right where you can search and load modules into your Python execution environment.