Root and Python

 
Home Research Classes

ROOT and Python on Windows

Version 4 of root includes pyROOT -- an interface between ROOT and Python. Python makes root that much more useful; I've found using python to be much better than using ROOT's C++ interface, CINT.

Unfortunately, the current default installations of root do not include a pre-built version of the python interface. This isn't hard to build from ROOT sources, but is painful if you want to install on multiple machines. Further, there are a bunch of environment variables you have to get right.

To solve this I've built ROOT locally, and used an open source installer creator for Windows to make an installer that should work on most Windows XP or better systems (not tested on Windows 2000 or less, but may work... try it??).

  1. Install Python 2.5.

    Download the Python Installer and run it on your windows machine. I'd suggest installing for all users. It is probably advisable to install it in a directory path that does not contain spaces.

    You don't actually need to install python if you don't want it -- the ROOT installer below will work just fine. In order for the ROOT-Python integration to work, you need to install Python version 2.4. 2.3's installer is very different, and, as a result, the ROOT installer won't discover python.
     

  2. Install ROOT

    Download the installer, run it. Make sure to install it to a path that does not include any spaces.

    • v4.03.02 - built against python 2.4.
    • v4.04.02
    • v5.04.00
    • v5.06.01 -- Fixes rootcint +p problems and also defines a rootmap file.
    • v5.06.02 -- Fixes attempt to write to C: (fails when running as non-priv user).
    • v5.06.03 -- Fixes a bug in root's TInterpreter class (on windows was defined differently in internal and external builds).
    • v5.08.01 -- This is a custom version of root, based on 5.08, which includes the TRef fixes.
    • v5.10.00
    • v5.11.02-1 -- This is the first version built against VS2005 instead of VS2003. You can't use this with 2003, and you can't use previous versions with 2005. From now on all will be built against 2005. The -1 is for a minor bug fix in the win32 gui code to prevent a crash.
    • v5.12.00
    • v5.12.14 -- This is the first version built against python 2.5. It isn't likely this will work with any earlier versions.

What You Get

  • Right click on any .root file and you can start root with that file opened. This is the same as invoking root with the filename as a program argument. NOTE: This is fixed with v5.04 an later.
  • Right click on any .C file and one of the options will be to invoke root to execute that file
  • Right click on any directory and invoke either root or pyROOT, with that directory as your working directory.
  • Invoke root or Python from the command line. In python you can of course say "import ROOT".
  • This is the standard version of root, built against the Windows library (i.e. not the cygwin version of root).

Known Bugs

  • When you uninstall root it won't remove the source files for root. This is a technical issue. Easy to fix, but tedious and requires a bunch of work.
  • If you install root first, and then install python, to get the python-root integration you need to hit "change" on the root entry in your add/remove software control panel, drill down to the python integration option, disable it. Then repeat, but enable it this time. This is due to my not understanding fully how msi's work on Windows.
  • Feature: Don't worry if when you first double click the installer it takes a while to get you to your first screen. That is normal; the installer is processing lots of files.
  • You get all source code and built libraries for root. This is because I couldn't get python to build and make install to work in the root build. This is also why the install package is 100 megs!
  • If you install this on Terminal Server anyone else logged in will have to log out to get the env variables properly defined.
  • If you have already defined ROOTSYS as a user ENV variable, that will override the ROOTSYS that is defined by this installer package (as a system env variable). You'll need to delete your user ROOTSYS before the system ROOTSYS will be used.
  • Missing Feature: It doesn't set up include directories for VS.NSET. I really want it to, but I've not found either the environment variable settings or the registry settings, or the automation interface for VS.NET that allows you to do this. If anyone knows what it is, please let me know!