ROOT cannot be called in VS Code

So to summarize: import ROOT works in regular python shell, but not in Jupyter notebook from VS Code, right?
Can you try root --notebook? If it works then it’s definitively an issue with your VS Code installation.

PS C:\Users\meles> root --notebook
PS C:\Users\meles> Error starting ROOT notebook -- please check that Jupyter is installed


OK can you install Jupyter and try again ?

I have installed both notebook and la with pip, but the error persists. Are there any paths I might need to specify?


Can you start Python from the command prompt (i.e. does python --version works)?
For example, on my machine:

C:\root-dev\build\x64\release>python --version
Python 3.10.11

BTW, I told you to start from a x64 Native Tools Command Prompt for VS 2022, not from PowerShell. Can you try?

Here is what I get in x64 Native Tools Command Prompt for VS 2022:

And my python is:

C:\Program Files\Microsoft Visual Studio\2022\Community>python --version
Python 3.8.10


OK, so forget root --notebook. But I see you can start ROOT without calling C:\root_v6.30.02\bin\thisroot.bat beforehand. How did you set-up your environment variables?

I added 3 new entries to system PATH:


And created a PYTHONPATH system variable with C:\root_v6.30.02\bin content.


OK, thanks.

Do you confirm that this statement is correct?

Yes, I can confirm it. If I add all aforementioned variables, I can import ROOT in Shell:

But I get critical problems, when I add PYTHONPATH variable. It crashes Jupiter cells (where I don’t use ROOT), and sometimes it even crashes my system (blue screen). There must be some severe packages conflict in my system, but I have no clue.


Well, in this case I’m not sure I can really help…

I faced the same problem with Jupyter (ipython) notebook kernel crash on Win 11. But I suspect the reason is faulty/incompatible with the local python build of distributed released binaries for Win.

I installed ROOT via root_v6.30.02.win64.vc17.exe from the release page which is precompiled for python=3.8.10 only. It looked fine at first: I could run ROOT from shell, I could import ROOT in python interactive shell and run few examples but trying to import ROOT in any ipython notebook would cause a kernel crash. Exactly the same behavior I’ve seen in all 3 cases:

  • running ipynotebok in VS Code via python extension
  • starting local jupyterlab server running jupyter notebook
  • even starting jupyter server in a recommended way: root .exe --notebook would crash

However, I managed to build ROOT 6.30.02 from source locally targeting clean install of python=3.10.11 and everything worked