Search code examples
pythonvisual-studio-codeanaconda

Python version in my VSCode notebook differs from the version of the virtual environment


Python environments confuse me very much. I had just formatted my PC and now I'm installing Anaconda+Python+VScode. First thing I did was to simply install Anaconda, with it Python version 3.11.7 was preinstalled. Then I created a virtual env conda create --name fbprophet. After which I installed VSCode and the Jupyter notebook extension, then created a .ipynb file. I'm then asked to select the kernel for the environment and at the moment I only have the (base) and the (fbprophet), both running on 3.11.7.

However, when doing a print(sys.version), it says I'm using Python 3.12.3!

I want to be able to work in the same venv, regardless of whether I'm writing a .py file or a .ipynb file. Can any one shed some light on how to get my way around this?

enter image description here


Solution

  • You have to select the python interpreter then choose your jupyter kernel in the upper right corner.

    enter image description here

    Read document for more details.