Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

You can install any available Python packages you need with either pip and/or conda. However, due to technical reasons the default environment will always reset between sessions, so we need take extra care to ensure that packages are installed on your own persistent storage instead of the default environment.

...

This will work both in the terminal and with a magic command within a notebook.

...

The setup for installing packages with conda is slightly more complicated, as we need to must create a new kernel to run your notebooks with. You should run all the commands in the terminalcan also install your packages to the 'base' environment, however everything you install there will be removed between sessions.

NOTE: The package manager installed on the hubs is micromamba, instead of conda. microamba is a lighter (and slightly faster) version implementation of the conda package manager. All the commands below (and almost any other mamba/conda commands) are completely interchangeable with conda; just change 'mamba' to 'conda' and the commands will work just the same.

You should run all the following commands in the terminal.


First we need to initialize the terminal to use conda by running these two commands. This step we ever only need to do once.

Code Block
mamba init

mv .bashrc .profile

For the changes to the take effect you must restart your terminal. After restarting, you will know that everything worked correctly if you see something like this in your terminal with your own username:

...

If initializing conda worked correctly, we can then create a new conda environment. With the '--prefix' flag we are creating an environment by specifying a location instead of a name - named environments will get removed between sessions. You can change the name location '~/myenv' to anything you might want.

Code Block
mamba create --prefix ~/myenv

mamba activate ~/myenv


Then we install the kernel and the new packages we want to use. For this simple example Iwe'm re only installing 'pytorch'. You must always make sure to include the 'ipykernel' package in the environment, no matter which other packages you want to install!

...