Jupyter Kernels with Pyenv

Recently I wanted to run jupyter from within a pyenv environment, and using the environment itself to have isolation of versions of the python modules installed. I was not satisfied with the blogs I found online so I tried my own approach.

First, I created a virtual environment using pyenv,

pyenv install 3.11.4
pyenv virtualenv 3.11.4 chatbots-3.11.4
pyenv activate
pip install jupyterlab ipykernel

Which installed jupyter within the virtual environment chatbots-3.11.4. Then I ran

python -m ipykernel install --name "chatbots-3.11.4" --user

Which allowed the virtual environment to be shown at the list of available kernels of jupyter when running

jupyter-lab

The kernel chatbots-3.11.4 is available

It worked as expected and with less instructions than I thought.

comments powered by Disqus