Jupyter notebooks in Visual Studio Code does not use the active virtual environment

It’s because there is an extra step needed – you need to explicitly install a Jupyter kernel that points to your new Python virtual environment. You can’t simply activate Jupyter-lab or Notebook from the virtual environment. This has tripped me up before, too.

Follow the advice here: Using Jupyter notebooks with a virtual environment

And, in fact, there can be an issue where your kernel still doesn’t point to the correct Python binary, in which case you need to change one suggestion in the above advice process:

From: ipython kernel install --user --name=projectname

To: python3 -m ipykernel install --user --name=projectname

(This correction comes from a comment to Jupyter Notebook is loading incorrect Python kernel #2563.)

*and don’t forget to restart VSCode

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)