ROOT cannot be called in VS Code

Hello experts,

I am having a problem with running ROOT on my new Windows device.

I’ve installed the latest 6.30.02 version for my Windows 11 laptop. I know that it is only compatible with Python 3.8.10, so I installed this version of Python and specified Path system variable to point to it. After installing ROOT, I can call it in PowerShell. I can also import ROOT in Python, if I start it in PowerShell.

To make sure that Python is compatible with ROOT:

PS C:\Users\meles> root -l
root [0] .q
PS C:\Users\meles> root-config --python-version
PS C:\Users\meles> python --version
Python 3.8.10

The problem although is, when I import ROOT in Jupiter notebook in VS Code, it crashes the kernel.

I have also added PYTHONPATH variable to point to bin directory of ROOT. If I remove it, it says that ROOT is unknown, but if I add it, the cell is being executed for some 60 seconds and crashes. I can’t fully understand logs, which are generated, so I an attaching them below.
crash.txt (68.8 KB)

Could you please advise me on how to deal with it?

Thank you in advance.


I never tried to start a Jupiter notebook in VS Code, and not sure if someone already did. In order to try I’ll have to set-up a dedicated environment, but not before mid next week…

Thank you for your reply. The disappointing thing is that this setup is working on my old laptop.


Then are you sure it’s a ROOT issue?

If you look into log file, it is pointing to Python 3.12 for some reason. Even though I point only to 3.8 in all system variables.

I doubt that it is a problem of root itself, but rather of how it is referred to. But I think this is the perfect community to bring up a question like this.


You should check which exact version is used by VS code (e.g. which extensions are installed)

I just checked, I have identical versions of VS Code, as well as Python and Jupiter extensions.

But I could also find the following lines in the python tab of “Output” panel:
2023-11-30 16:44:32.583 [warning] Identifier for virt-virtualenv failed to identify

C:\Users\meles\AppData\Local\Programs\Python\Python312\python.exe [Error: ENOENT: no such file or directory, scandir 'C:\Users\meles\AppData\Local\Programs\Python\Python312'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'scandir',
  path: 'C:\\Users\\meles\\AppData\\Local\\Programs\\Python\\Python312'

I have no idea which module, why and what for is looking for Python 3.12, as well as how to fix it.



May I draw your attention please to this question. It remains relevant for me.
Thank you!


Did you try to uninstall Python 3.12 (wherever it comes from)? I can also try to mess up a virtual machine, but that will take a bit of time…

Unfortunately, I can’t find any leftovers of Python 3.12 anywhere.


OK, I’ll try to find out

I am still convinced that this is some VS Code problem, the way it is configured. Since I can call ROOT in python in shell.

Thank you.


So I installed the Jupyter extension in VS code, and I can import ROOT without problem:

I wish it was the case for me. Could you please have a look into the log file I attached in the first post?


I did already. Anyway, I’ll dig more into it and try to guess…

I’ve been working on the different stuff in the meantime and came across the same kernel crash, when executing the following lines, which do not include ROOT:

# import ROOT
import uproot
import numpy as np

tree ="./root_files/B.sim.rec.roi.root:tree")
branches = ['PXDClusters/PXDClusters.m_clsCharge','PXDClusters/PXDClusters.m_clsSize']
df = tree.arrays(branches, library="pd")


To say more, the crash takes place only when I add the last line (display). Crash log looks the same. I am even more puzzled now…

Just for a test, I installed 3.12 and ran this cell with it. I run it once, second time, etc. - it is being executed. Then, after some random execution of the same code, it just crashes the kernel.


So it looks like the issue is in your environment…
Anyway, can you try to start VS Code from a x64 Native Tools Command Prompt for VS 2022, in your home directory, after calling C:\root_v6.30.02\bin\thisroot.bat, and try again to create a Notebook from there?

Thank you for the suggestion. I tried it, but the issue persists, no change.


One more question: which version of ROOT did you download (the exact name)?

It was root_v6.30.02.win64.vc17.exe