ROOT Version: root_v6.30.06 Platform: Windows Compiler: Visual Studio Code
I completed all of the steps to download all of the dependencies and then downloaded the latest version of root. Updated the environment variables to include “thisroot.sh” and “thisroot.bat” (I wasn’t sure which one was right so both were added) , and am able to run “root” in the terminal. However, I cannot import ROOT in my code. I still get the “ModuleNotFoundError”. Could it be a missing python binding? Could someone please help me troubleshoot the problem?
Hi,
Yes, I can run “root” in the terminal. The error arises when I try “import ROOT” with my python script.
The error is “ModuleNotFoundError: No module named ‘ROOT’”.
Just for reference about the python version: $root-config --python-version 3.11.7
$python Python 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
So, I think the python version can be ruled out for this issue.
Yeah, thisroot.bat should have achieved that, but somehow it didn’t work either for me and I had to add the path via sys. I do not know why it’s failing. Maybe @bellenot knows.
I cannot reproduce the issue. thisroot.bat properly sets the environment variables:
C:\Users\bellenot\Downloads\root>bin\thisroot.bat
C:\Users\bellenot\Downloads\root>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>>
Hmm maybe it was because of running from a Powershell instead of a CMD shell.
(The other less likely explanation might be when having multiple Python versions installed in the system, calling C:\Programs\python3.11 might ignore PYTHONPATH. )
Hi I’m having the same issue on VS code.
I’ve installed everything thats needed and unarchived the root folder. I tried to do the import sys and append method provided above but its still not working. I have the same Root Version, Platform, and Compiler as the original poster of this thread.
When running with VS code embedded terminal, try switching from “powershell” to “cmd”. I did that and it solved it for me.
(I called first vcvarsall.bat as it’s done when you start x64 native tools)
I didn’t append the path through lib . I still used bat. It is strange however how running the batch file in cmd works but not in powershell. To be honest, I dont really know the difference between them.