Problem running PyROOT on cygwin

I have both Python 2.6 and root 5.27 installed on my Windows 7 machine and I can run PyROOT applications under windows just fine. However, I want to be able to run in Cygwin (much nicer user environment). I can get both Python and root to run individually in Cygwin, but when I try “import ROOT” in python, I get the error message No Module Named ROOT. I was assuming this was a problem with paths so I added C:/root/bin (where ROOT.py is located) to my pythonpath in Cygwin - but it still doesn’t work. I am new to coding in windows so please be very (syntax) specific on how to specify paths in your answers :confused:

I use PyRoot on Cygwin a lot. First question: Did you set up your environment correctly?

cplager@tableau> printenv | grep -i root CVSROOT=cdfcvs@cdfcvs.fnal.gov:/cdf/code/cdfcvs/run2 LD_LIBRARY_PATH=/usr/local/bin/root/lib:/lib: PATH=/usr/local/bin/root:/usr/bin:/usr/local/bin:/usr/local/netpbm/bin:/home/cplager/bin:/usr/bin:/home/cplager/bin:/cygdrive/c/Program Files/MiKTeX 2.7/miktex/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/GhostView/gs8.63/bin:/cygdrive/c/PROGRA~1/COMMON~1/SONICS~1/:/cygdrive/c/PROGRA~1/COMMON~1/MUVEET~1/030625:/usr/local/bin/root/bin/:/usr/X11R6/bin/:.::/usr/X11R6/bin/:/usr/local/packages/cern/bin:/usr/local/bin/kerberos:. ROOTSYS=/usr/local/bin/root PYTHONPATH=/usr/local/bin/root/lib:

Cheers,
Charles

Hi,

no access to a windows box right now, but you can pick up from the python prompt which paths are visible by looking at sys.path, and using os.path.exists() to see whether the individual elements are “translated” properly (drive numbers etc.).

Cheers,
Wim

Thanks for your help. When I try sys.path in python I get the following:
[’’, ‘/cygdrive/c/root/lib’, ‘/home/gatu/C’, ‘/home/gatu/\root\bin’, ‘/usr/lib
/python26.zip’, ‘/usr/lib/python2.6’, ‘/usr/lib/python2.6/plat-cygwin’, ‘/usr/li
b/python2.6/lib-tk’, ‘/usr/lib/python2.6/lib-old’, ‘/usr/lib/python2.6/lib-dynlo
ad’, ‘/usr/lib/python2.6/site-packages’, ‘/usr/lib/python2.6/site-packages/gtk-2
.0’]

The line ‘/home/gatu/\root\bin’ looks very suspicious to me, but I would have thought ‘/cygdrive/c/root/lib’ would be enough to make it work (that is the folder where ROOT.py is found)? (I still get “Import Error: No module named ROOT”)

I also tried to get the root environment variables at the cygwin prompt but I find the result a bit hard to interpret:
$ printenv | grep -i root
MANPATH=/cygdrive/c/root/man:/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/ma
n
LD_LIBRARY_PATH=/cygdrive/c/root/lib:c:/clhep/2.1.0.0/lib
LIBPATH=/cygdrive/c/root/lib:C:\Windows\Microsoft.NET\Framework\v3.5;C:\Windows
Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0
VC\LIB;
PATH=/cygdrive/c/root/bin:/usr/local/bin:/usr/bin:/bin:/cygdrive/c/Program Files
/Microsoft Visual Studio 9.0/Common7/IDE:/cygdrive/c/Program Files/Microsoft Vis
ual Studio 9.0/VC/BIN:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Comm
on7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Windows/M
icrosoft.NET/Framework/v2.0.50727:/cygdrive/c/Program Files/Microsoft Visual Stu
dio 9.0/VC/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.0A/bin
:/cygdrive/c/Program Files/LANL/MCNP5/mcnp5/bin/Windows:/cygdrive/c/Windows/syst
em32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/S
ystem32/WindowsPowerShell/v1.0/:/cygdrive/c/Program Files/Intel/DMIX:/cygdrive/c
/Program Files/Intel/WiFi/bin/:/cygdrive/c/Program Files/Common Files/Intel/Wire
lessCommon/:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software/:/cygdrive/c/Pr
ogram Files/NTRU Cryptosystems/NTRU TCG Software Stack/bin/:/cygdrive/c/Program
Files/Wave Systems Corp/Gemalto/Access Client/v5/:/cygdrive/c/Program Files/Comm
on Files/Roxio Shared/DLLShared/:/cygdrive/c/Program Files/Common Files/Roxio Sh
ared/10.0/DLLShared/:/cygdrive/c/root/bin:/usr/lib/lapack:C:/Users/gatu/Document
s/MIT/Geant4/bin/WIN32-VC
ROOTSYS=C:\root
DYLD_LIBRARY_PATH=/cygdrive/c/root/lib
SYSTEMROOT=C:\Windows
PYTHONPATH=/cygdrive/c/root/lib:C:\root\bin
SHLIB_PATH=/cygdrive/c/root/lib

Any new hints and tips based on these results?

[quote=“mgatu”]Thanks for your help. When I try sys.path in python I get the following:

['', '/cygdrive/c/root/lib', '/home/gatu/C', '/home/gatu/\\root\\bin', '/usr/lib
/python26.zip', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-cygwin', '/usr/li
b/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynlo
ad', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/gtk-2
.0']

The line ‘/home/gatu/\root\bin’ looks very suspicious to me, but I would have thought ‘/cygdrive/c/root/lib’ would be enough to make it work (that is the folder where ROOT.py is found)? (I still get “Import Error: No module named ROOT”)

I also tried to get the root environment variables at the cygwin prompt but I find the result a bit hard to interpret:

$ printenv | grep -i root
MANPATH=/cygdrive/c/root/man:/usr/local/man:/usr/share/man:/usr/man::/usr/ssl/ma
n
LD_LIBRARY_PATH=/cygdrive/c/root/lib:c:/clhep/2.1.0.0/lib
LIBPATH=/cygdrive/c/root/lib:C:\Windows\Microsoft.NET\Framework\v3.5;C:\Windows\
Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0\
VC\LIB;
PATH=/cygdrive/c/root/bin:/usr/local/bin:/usr/bin:/bin:/cygdrive/c/Program Files
/Microsoft Visual Studio 9.0/Common7/IDE:/cygdrive/c/Program Files/Microsoft Vis
ual Studio 9.0/VC/BIN:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Comm
on7/Tools:/cygdrive/c/Windows/Microsoft.NET/Framework/v3.5:/cygdrive/c/Windows/M
icrosoft.NET/Framework/v2.0.50727:/cygdrive/c/Program Files/Microsoft Visual Stu
dio 9.0/VC/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.0A/bin
:/cygdrive/c/Program Files/LANL/MCNP5/mcnp5/bin/Windows:/cygdrive/c/Windows/syst
em32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/S
ystem32/WindowsPowerShell/v1.0/:/cygdrive/c/Program Files/Intel/DMIX:/cygdrive/c
/Program Files/Intel/WiFi/bin/:/cygdrive/c/Program Files/Common Files/Intel/Wire
lessCommon/:/cygdrive/c/Program Files/WIDCOMM/Bluetooth Software/:/cygdrive/c/Pr
ogram Files/NTRU Cryptosystems/NTRU TCG Software Stack/bin/:/cygdrive/c/Program
Files/Wave Systems Corp/Gemalto/Access Client/v5/:/cygdrive/c/Program Files/Comm
on Files/Roxio Shared/DLLShared/:/cygdrive/c/Program Files/Common Files/Roxio Sh
ared/10.0/DLLShared/:/cygdrive/c/root/bin:/usr/lib/lapack:C:/Users/gatu/Document
s/MIT/Geant4/bin/WIN32-VC
ROOTSYS=C:\root
DYLD_LIBRARY_PATH=/cygdrive/c/root/lib
SYSTEMROOT=C:\Windows
PYTHONPATH=/cygdrive/c/root/lib:C:\root\bin
SHLIB_PATH=/cygdrive/c/root/lib

Any new hints and tips based on these results?[/quote]

You are mixing windows paths and posix (i.e., linux/cygwin) paths together. Don’t do that. If you are running with Cygwin’s python, it expects posix paths and will not understand windows. I could easily imagine this messing things up.

Try cleaning that up and see what happens. I can imagine having two version of your environment, 1 for Root/VC++ and the other for Root/GCC.

Cheers,
Charles

I have tried to clean up my paths a lot. I am also fairly confident now that the python used in cygwin is the one I installed myself under Windows 7, installed in C:/Python26. This is the version of python that works with the pyroot module directly under windows. However, I STILL get the message “ImportError: No module named ROOT” when trying to import ROOT in python in cygwin (though both python and ROOT both run individually). It could be mentioned that ROOT.py is located in C:/root/bin, and that I explicitly added this path to the pythonpath. New “printenv |grep -i root” result:

$ printenv |grep -i root
MANPATH=/cygdrive/c/root/man:/cygdrive/c/root/man:/cygdrive/c/root/man:/cygdrive
/c/root/man:/cygdrive/c/root/man:/cygdrive/c/root/man:/cygdrive/c/root/man:/cygd
rive/c/root/man:/cygdrive/c/root/man:/cygdrive/c/root/man:/cygdrive/c/root/man:/
cygdrive/c/root/man:/cygdrive/c/root/man:/cygdrive/c/root/man:/usr/local/man:/us
r/share/man:/usr/man::/usr/ssl/man
LD_LIBRARY_PATH=C:/root/lib:C:/lib:
LIBPATH=C:/root/lib
PATH=C:/root:C:/root/bin:/usr/bin:/usr/local/bin:/usr/local/netpbm/bin:/home/gat
u/bin:/usr/bin:/cygdrive/c/root/bin:C:/root:C:/root/bin:/usr/bin:/usr/local/bin:
/usr/local/netpbm/bin:/home/gatu/bin:/usr/bin:/cygdrive/c/root/bin:C:/root:C:/ro
ot/bin:/usr/bin:/usr/local/bin:/usr/local/netpbm/bin:/home/gatu/bin:/usr/bin:/cy
gdrive/c/Program:C:/Users/gatu/Documents/MIT/Geant4/bin/WIN32-VC:C:/Users/gatu/D
ocuments/MIT/Geant4/bin/WIN32-VC
ROOTSYS=C:/root
DYLD_LIBRARY_PATH=C:/root/lib
SYSTEMROOT=C:/Windows
PYTHONPATH=C:/Python26:C:/root/lib:C:/root/bin
SHLIB_PATH=C:/root/lib

I might add that I also run Geant4 under cygwin and was specifically prompted during Geant4 installation NOT to specify paths in posix format, but as C:/…/… etc.

Please, help me!

[quote=“mgatu”]I have tried to clean up my paths a lot. I am also fairly confident now that the python used in cygwin is the one I installed myself under Windows 7, installed in C:/Python26. This is the version of python that works with the pyroot module directly under windows. However, I STILL get the message “ImportError: No module named ROOT” when trying to import ROOT in python in cygwin (though both python and ROOT both run individually). It could be mentioned that ROOT.py is located in C:/root/bin, and that I explicitly added this path to the pythonpath. New “printenv |grep -i root” result:
[/quote]

Wait… Which python are you trying to use?

Using Cygwin/gcc version of root works very well (and easily) with Cygwin’s python. But I would be surprised if it works with a non-cygwin python.

Cheers,
Charles