Pycharm 4 no module named ROOT, when importing a locally installed module (PyROOT), that is working fine from shell on Mac OS X Yosemite

Hi Folks,
I am trying to Configure PyROOT in order to work with Pycharm 4 on Mac OS X Yosemite. so, I have installed ROOT (locally), by enabling the python option, and set up all of the necessary environment paths.


And It works just fine from the shell interpreter:

Python 2.7.6 (default, Sep  9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
>>> ROOT.__file__

In Pycharm I have tried to add these paths to the interpreter using Preferences->Project Interpreter->More->Show paths…

The paths that show there are the following:


and then I created the following file in Pycharm:

import os
os.system("echo $PYTHONPATH")
import ROOT

When run, it returns this:

Traceback (most recent call last):
 File "/Users/natalia/Work/Projects/untitled/", line 3, in <module>
    import ROOT
ImportError: No module named ROOT

Notice how this PYTHONPATH that’s printed from python in Pycharm doesn’t include (for a reason unknown to me) the path that actually includes the ROOT.pyc file, that is: '/Users/natalia/Software/root/lib'

I have also tried doing the dirty trick of

os.system("export PYTHONPATH=$PYTHONPATH:/Users/natalia/Software/root/lib")
but I found it doesn’t actually change the path if I print it afterwards.

I am totally confused as to where Pycharm gets the paths from?? Any possible solutions would be welcome and greatly appreciated.

Thanks & Regards
Python Programmer

os.system("export PYTHONPATH=$PYTHONPATH:/Users/natalia/Software/root/lib")

runs a sub-shell where the path gets modified, it can not affect the current process, nor can os.environ or os.putenv.

If you want to modify “PYTHONPATH” dynamically for the current proces, then change sys.path.

Beyond that, I’m not familiar with Pycharm. Just like to add that cppyy master has a far more functional implementation of __dir__ then does the version that lives under PyROOT. This will help with code completion in any IDE.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.