Versions Compared

Key

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

...

pip has a built-in '--user' flag that will automatically install new packages to the user environment. It is very simple to use, just include the flag in your pip install command;


Code Block
pip install --user package_name


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

...

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. You can change the name 'myenv' to anything you might want.


Code Block
mamba create --prefix ~/myenv

...



mamba activate ~/myenv



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


Code Block
mamba install ipykernel pytorch



Finally we need to register the kernel, so that Jupyter can use it. You can change the name and display name to anything you might want. You can also completely omit the display name if you prefer.


Code Block
ipython kernel install --user --name=mykernel --display-name="Kernel with pytorch"



The new kernel with the installed packages should now be available for you to use for your notebooks.

...