# 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:** 13\
**Page:** 2

<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, 2:39pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/21 "2023-12-06T14:39:06Z")

</div>

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.

---

<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, 3:06pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/22 "2023-12-06T15:06:30Z")

</div>

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

```

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, 3:12pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/23 "2023-12-06T15:12:10Z")

</div>

OK can you install Jupyter and try again ?

---

<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, 3:30pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/24 "2023-12-06T15:30:14Z")

</div>

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

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, 3:33pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/25 "2023-12-06T15:33:12Z")

</div>

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

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

```

---

<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, 3:37pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/26 "2023-12-06T15:37:08Z")

</div>

> [@mc.dmytro](#):
>
> ```auto
> PS C:\Users\meles> root --notebook
> PS C:\Users\meles> Error starting ROOT notebook -- please check that Jupyter is installed
> 
> ```

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

---

<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, 3:43pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/27 "2023-12-06T15:43:09Z")

</div>

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

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

And my python is:

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

```

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, 3:48pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/28 "2023-12-06T15:48:27Z")

</div>

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?

---

<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, 4:02pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/29 "2023-12-06T16:02:35Z")

</div>

I added 3 new entries to system PATH:

```auto
C:\root_v6.30.02\bin
C:\Users\meles\AppData\Local\Programs\Python\Python38\Scripts\
C:\Users\meles\AppData\Local\Programs\Python\Python38

```

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

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, 4:05pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/30 "2023-12-06T16:05:37Z")

</div>

OK, thanks.

> [@bellenot](#):
>
> So to summarize: `import ROOT` works in regular python shell, but not in Jupyter notebook from VS Code, right?

Do you confirm that this statement is correct?

---

<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, 4:16pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/31 "2023-12-06T16:16:44Z")

</div>

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

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

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.

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, 4:21pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/32 "2023-12-06T16:21:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![NazyS](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/nazys/32/35215_2.png) [@NazyS](https://root-forum.cern.ch/u/NazyS)\
**Post date:** [December 6, 2023, 10:46pm UTC](https://root-forum.cern.ch/t/root-cannot-be-called-in-vs-code/57343/33 "2023-12-06T22:46:36Z")

</div>

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

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