# Python not detecting ROOT

**URL:** <https://root-forum.cern.ch/t/python-not-detecting-root/62728>\
**Category:** Newbie\
**Created:** [January 22, 2025, 8:11pm UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728 "2025-01-22T20:11:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Sharma](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aditya_sharma/32/36805_2.png) [@Aditya\_Sharma](https://root-forum.cern.ch/u/Aditya_Sharma)\
**Post date:** [January 22, 2025, 8:11pm UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/1 "2025-01-22T20:11:57Z")

</div>

I have downloaded ROOT via root\_v6.32.08.win32.vc17 given on website and have created a virtual environment “C:\32 bit Python for ROOT\venv\_root” and I am still not able to import root in python. I am using ‘python 3.13.something’ and I even tried ‘python 3.12.7’.

```auto
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Aditya>cd C:\32 bit Python for ROOT

C:\32 bit Python for ROOT>venv_root\Scripts\activate

(venv_root) C:\32 bit Python for ROOT>python --version
Python 3.13.1

(venv_root) C:\32 bit Python for ROOT>python
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 18:47:25) [MSC v.1942 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import ROOT
ModuleNotFoundError: No module named 'ROOT'
>>>

```

_ROOT Version:_ 6.32.08  
_Platform:_ Windows  
_Compiler:_ MVSC

* * *

---

<div class="post-metadata">

**Author:** ![devajith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/devajith/32/37165_2.png) [@devajith](https://root-forum.cern.ch/u/devajith)\
**Post date:** [January 22, 2025, 9:49pm UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/2 "2025-01-22T21:49:34Z")

</div>

Hi Aditya,

Thank you for your question. I don’t use windows, but I was thinking maybe you can fix the issue by just running: ‘bin\thisroot.bat’

@bellenot can help you, if that doesn’t fix it.

Cheers,  
Dev

---

<div class="post-metadata">

**Author:** ![Aditya\_Sharma](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aditya_sharma/32/36805_2.png) [@Aditya\_Sharma](https://root-forum.cern.ch/u/Aditya_Sharma)\
**Post date:** [January 23, 2025, 6:01am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/3 "2025-01-23T06:01:06Z")

</div>

I tried the following:

```auto
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Aditya>"C:\root_v6.32.08\bin\thisroot.bat"

C:\Users\Aditya>C:\32 bit Python for ROOT\venv_root\Scripts\activate
'C:\32' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\Aditya>cd C:\32 bit Python for ROOT\venv_root\Scripts\activate
The directory name is invalid.

C:\Users\Aditya>cd "C:\32 bit Python for ROOT\venv_root\Scripts\activate"
The directory name is invalid.

C:\Users\Aditya>cd "C:\32 bit Python for ROOT\"

C:\32 bit Python for ROOT>venv_root\Scripts\activate

(venv_root) C:\32 bit Python for ROOT>python --version
Python 3.13.1

(venv_root) C:\32 bit Python for ROOT>python
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 18:47:25) [MSC v.1942 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File ←[35m"<python-input-0>"←[0m, line ←[35m1←[0m, in ←[35m<module>←[0m
    import ROOT
  File ←[35m"C:\root_v6.32.08\bin\ROOT\ __init__.py"←[0m, line ←[35m25←[0m, in ←[35m<module>←[0m
    import cppyy
  File ←[35m"C:\root_v6.32.08\bin\cppyy\ __init__.py"←[0m, line ←[35m81←[0m, in ←[35m<module>←[0m
    from ._cpython_cppyy import *
  File ←[35m"C:\root_v6.32.08\bin\cppyy\_cpython_cppyy.py"←[0m, line ←[35m22←[0m, in ←[35m<module>←[0m
    import libcppyy as _backend
←[1;35mImportError←[0m: ←[35mDLL load failed while importing libcppyy: The specified module could not be found.←[0m
←[?25l←[1A
←[?25l←[?25l←[1;35m>>> ←[0m←[4D←[?25h←[4C←[?25l←[?25h←[?25l←[?25h←[4D
←[?25l←[1A
←[?25l←[?25l←[1;35m>>> ←[0m←[4D←[?25h←[4C

```

but still got an error.

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [January 23, 2025, 6:18am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/4 "2025-01-23T06:18:02Z")

</div>

Hi @Aditya_Sharma,

you are using Python 3.13.1, but as explained [on the ROOT website somewhere](https://root.cern/install/dependencies/#windows): “If you download a binary release, you need to install the exact same Python version used for the compilation of the binary.”

That’s why you get the crash I guess. Sorry if this wasn’t clear. We are making this more explicit in [ROOT 6.34](https://root.cern/releases/release-63402/) by putting the Python version used at the build into the binary name, e.g. `root_v6.34.02.win32.python311.vc17`. You can also double check this in [out build logs](https://productionresultssa15.blob.core.windows.net/actions-results/ed75c03e-39fd-49e3-98f3-6f709f5a55f2/workflow-job-run-4c3ea338-fbc5-57dc-1191-52790a263031/logs/job/job-logs.txt?rsct=text%2Fplain&se=2025-01-23T06%3A19%3A54Z&sig=Q3GRlfRZJC%2BKiRwD4setBtBcpG5Up2j3o9GbDNSaazY%3D&ske=2025-01-23T18%3A06%3A45Z&skoid=ca7593d4-ee42-46cd-af88-8b886a2f84eb&sks=b&skt=2025-01-23T06%3A06%3A45Z&sktid=398a6654-997b-47e9-b12b-9515b896b4de&skv=2024-11-04&sp=r&spr=https&sr=b&st=2025-01-23T06%3A09%3A49Z&sv=2024-11-04), which indeed say:

```txt
2025-01-22T08:04:09.9367575Z -- Looking for Python
2025-01-22T08:04:11.5611302Z -- Found Python3: C:/Python311/python.exe (found suitable version "3.11.7", minimum required is "3.8") found components: Interpreter Development NumPy Development.Module Development.Embed

```

I hope it will work just fine if you use the suitable Python version.

---

<div class="post-metadata">

**Author:** ![Aditya\_Sharma](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aditya_sharma/32/36805_2.png) [@Aditya\_Sharma](https://root-forum.cern.ch/u/Aditya_Sharma)\
**Post date:** [January 23, 2025, 6:21am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/5 "2025-01-23T06:21:04Z")

</div>

Ah yes I also tried python 3.11.7 but on using pip list global modules were not shown in the list even though I used `--system-site-packages` while creating the virtual environment.

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [January 23, 2025, 6:42am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/6 "2025-01-23T06:42:27Z")

</div>

Ok, so that means you have no ROOT-related problem when using Python 3.11.7?

---

<div class="post-metadata">

**Author:** ![Aditya\_Sharma](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aditya_sharma/32/36805_2.png) [@Aditya\_Sharma](https://root-forum.cern.ch/u/Aditya_Sharma)\
**Post date:** [January 23, 2025, 9:23am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/7 "2025-01-23T09:23:17Z")

</div>

I meant that in python 3.11.7 the ROOT problem is still there along with the problems with global packages.

```auto
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Aditya>cd "C:\Python 3.11.7 32bit\"

C:\Python 3.11.7 32bit>"C:\Python 3.11.7 32bit\python\python.exe" -m venv --system-site-packages myenv

C:\Python 3.11.7 32bit>myenv\Scripts\activate

(myenv) C:\Python 3.11.7 32bit>python --version
Python 3.11.7

(myenv) C:\Python 3.11.7 32bit>pip list
Package Version
---------- -------
pip 23.2.1
setuptools 65.5.0

[notice] A new release of pip is available: 23.2.1 -> 24.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip

(myenv) C:\Python 3.11.7 32bit>

```

This is what I get with pip list.  
And now when I try to import ROOT:

```auto
Microsoft Windows [Version 10.0.26100.2894]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Aditya>"C:\Python 3.11.7 32bit\myenv\Scripts\activate.bat"

(myenv) C:\Users\Aditya>python --version
Python 3.11.7

(myenv) C:\Users\Aditya>pip list
Package Version
---------- -------
pip 23.2.1
setuptools 65.5.0

[notice] A new release of pip is available: 23.2.1 -> 24.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip

(myenv) C:\Users\Aditya>python
Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:13:08) [MSC v.1937 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ROOT'
>>>

```

And root is present in system environment variables.

```auto
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Users\Aditya> root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.34.02 https://root.cern |
  | (c) 1995-2024, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win32 on Dec 15 2024, 07:44:19 |
  | From tags/v6-34-02@v6-34-02 |
  | With MSVC 19.39.33521.0 |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0]

```

---

<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:** [January 23, 2025, 9:41am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/8 "2025-01-23T09:41:49Z")

</div>

```auto
(myenv) C:\Python 3.11.7 32bit>\root_v6.32.08\bin\thisroot.bat

(myenv) C:\Python 3.11.7 32bit>python
Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec 4 2023, 19:13:08) [MSC v.1937 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>>

```

---

<div class="post-metadata">

**Author:** ![Aditya\_Sharma](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/aditya_sharma/32/36805_2.png) [@Aditya\_Sharma](https://root-forum.cern.ch/u/Aditya_Sharma)\
**Post date:** [January 23, 2025, 10:53am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/9 "2025-01-23T10:53:12Z")

</div>

Ok yes it worked.  
But I am unable to use import Root in VS code can you help with that?

---

<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:** [January 23, 2025, 11:37am UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/10 "2025-01-23T11:37:35Z")

</div>

Not really… Did you try to [search on the Forum](https://root-forum.cern.ch/search?q=import%20Root%20in%20VS%20code%20order%3Alatest)?

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [January 23, 2025, 5:21pm UTC](https://root-forum.cern.ch/t/python-not-detecting-root/62728/11 "2025-01-23T17:21:58Z")

</div>

Probably you need to call thisroot.ps instead of thisroot.bat if you are running from a PowerShell.  
Or alternatively changing the VScode default terminal to the cmd one.
