This guide will show you how to create a custom Conda Virtual Environment and use it to launch the notebook. You can use these custom-built environment to install Python/Conda libraries which are not part of the existing environment.
Steps to Create
Open a Terminal
Notebook and run the following commands.
-
Initialize the environment:
cd ~ # Make sure you are in the HOME directory. conda init bash source .bashrc
-
Create an environment file: For the example sake, we are assuming that the library we want to install is
arrow
, name of the environment ismyenv
and environment file name isenv.yml
. The content of the environment file would be as follows:name: myenv channels: - conda-forge dependencies: - python==3.7 - pip: - arrow - ipykernel
-
Create and activate the environment:
conda env create -f env.yml conda activate myenv
-
Create a kernel with the environment:
python -m ipykernel install --user --name=myenv --display-name="MyEnv" # Reload the browser to refelect the installed kernel
Example Notebook
In the following example, you will use a newly installed kernel.
Open a Python Notebook
, select kernel MyEnv
and put the following in a code cell:
import arrow
utc = arrow.utcnow()
utc = utc.shift(hours=-1)
local = utc.to('US/Pacific')
local.humanize()
Expected output would be:
an hour ago