How to Avoid Environment Conflicts in Jupyter Notebooks

Raymond Lo, PhD
2 min readOct 21, 2024

--

Dependency conflicts no more.

As developers, we have all spent many hours debugging one thing: dependency conflicts.

Here I will provide a 1 minute tutorial that will save you hours later by setting up a separate environment per notebook. This way each notebook will not self-destruct when we perform any environment updates such as pip install a new package.

First, we start by creating a new environment and activate it.

python -m venv flux_env
source flux_env/bin/activate

Then, we will install the base environment in OpenVINO Notebooks as usual:

python -m pip install --upgrade pip
pip install -r openvino_notebooks/requirements.txt

Lastly, here we attach this new environment as a new kernel

python -m ipykernel install --user --name=flux_env

That will create a new folder here

/home/raymondlo84/.local/share/jupyter/kernels/flux_env , and a kernel.json file.

#"~/.local/share/jupyter/kernels/flux_env/kernel.json"

{
"argv": [
"/home/raymondlo84/flux_env/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"display_name": "flux_env",
"language": "python",
"metadata": {
"debugger": true
}
}

When you run OpenVINO Notebooks with Jupyter, you will see a new kernel in that list. Now you select that before you run any code. That’s it. All changes such as pip install will be contained within the kernel (flux_env) and no longer shared across all notebooks.

New kernel inside OpenVINO Notebooks
And Run!

Happy coding!

About the Authors

Raymond Lo, currently based in Silicon Valley, is the global lead of Intel’s AI evangelist team, focusing on the OpenVINO™ Toolkit. With a diverse background that includes founding the augmented reality company Meta, Raymond has also held key roles at Samsung NEXT and Google Cloud AI. His work spans startup entrepreneurship and enterprise innovation, with a strong presence in global conferences like TED Talks and SIGGRAPH.

--

--

Raymond Lo, PhD
Raymond Lo, PhD

Written by Raymond Lo, PhD

@Intel - OpenVINO AI Software Evangelist. ex-Google, ex-Samsung, and ex-Meta (Augmented Reality) executive. Ph.D. in Computer Engineer — U of T.

Responses (1)