# ROOT cannot be called in VS Code

**URL:** <https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343>\
**Category:** Newbie\
**Tags:** root\
**Created:** [November 30, 2023, 2:37pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343 "2023-11-30T14:37:37Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [November 30, 2023, 2:37pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/1 "2023-11-30T14:37:38Z")

</div>

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:

```auto
PS C:\Users\meles> root -l
root [0] .q
PS C:\Users\meles> root-config --python-version
 3.8.10
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](https://root-forum.cern.ch/uploads/short-url/bJeLU8EjcQX3OR1P24WJA3hV2tN.txt) (68.8 KB)

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

Thank you in advance.

Dmytro.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [November 30, 2023, 2:49pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/2 "2023-11-30T14:49:50Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [November 30, 2023, 3:01pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/3 "2023-11-30T15:01:37Z")

</div>

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

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [November 30, 2023, 3:02pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/4 "2023-11-30T15:02:47Z")

</div>

Then are you sure it’s a ROOT issue?

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [November 30, 2023, 3:04pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/5 "2023-11-30T15:04:41Z")

</div>

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.

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [November 30, 2023, 3:09pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/6 "2023-11-30T15:09:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [November 30, 2023, 3:48pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/7 "2023-11-30T15:48:35Z")

</div>

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

```auto
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.

D.

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [December 5, 2023, 3:31pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/8 "2023-12-05T15:31:05Z")

</div>

Hi!

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

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [December 5, 2023, 3:34pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/9 "2023-12-05T15:34:21Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [December 5, 2023, 3:35pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/10 "2023-12-05T15:35:33Z")

</div>

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

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [December 5, 2023, 3:37pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/11 "2023-12-05T15:37:04Z")

</div>

OK, I’ll try to find out

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [December 5, 2023, 3:38pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/12 "2023-12-05T15:38:56Z")

</div>

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.

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [December 5, 2023, 4:00pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/13 "2023-12-05T16:00:35Z")

</div>

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

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/3/b/3b9c394b9f6d679d02928e349f34279bf652a6f0.png)

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [December 5, 2023, 4:09pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/14 "2023-12-05T16:09:26Z")

</div>

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

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [December 5, 2023, 4:15pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/15 "2023-12-05T16:15:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [December 5, 2023, 5:11pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/16 "2023-12-05T17:11:22Z")

</div>

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:

```auto
# import ROOT
import uproot
import numpy as np

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

display(df)

```

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.

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [December 6, 2023, 7:55am UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/17 "2023-12-06T07:55:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [December 6, 2023, 11:14am UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/18 "2023-12-06T11:14:23Z")

</div>

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

D.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [December 6, 2023, 1:20pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/19 "2023-12-06T13:20:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mc.dmytro](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/58956e/32.png) [@mc.dmytro](https://root-forum.cern.ch/u/mc.dmytro)\
**Post date:** [December 6, 2023, 2:29pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/20 "2023-12-06T14:29:00Z")

</div>

It was [root\_v6.30.02.win64.vc17.exe](https://root.cern/download/root_v6.30.02.win64.vc17.exe)

D.

[Next page](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343.md?page=2)
