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

**URL:** <https://root-forum.cern.ch/t/pycharm-4-no-module-named-root-when-importing-a-locally-installed-module-pyroot-that-is-working-fine-from-shell-on-mac-os-x-yosemite/29898>\
**Category:** ROOT\
**Tags:** python, root\
**Created:** [July 21, 2018, 6:55am UTC](https://root-forum.cern.ch/t/pycharm-4-no-module-named-root-when-importing-a-locally-installed-module-pyroot-that-is-working-fine-from-shell-on-mac-os-x-yosemite/29898 "2018-07-21T06:55:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TejswiniUL](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tejswiniul/32/16709_2.png) [@TejswiniUL](https://root-forum.cern.ch/u/TejswiniUL)\
**Post date:** [July 21, 2018, 6:55am UTC](https://root-forum.cern.ch/t/pycharm-4-no-module-named-root-when-importing-a-locally-installed-module-pyroot-that-is-working-fine-from-shell-on-mac-os-x-yosemite/29898/1 "2018-07-21T06:55:57Z")

</div>

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.

```auto
echo $PYTHONPATH
/Users/natalia/Software/root/lib:/Users/natalia/Software/root/bin:/Users/natalia/Software/root

```

And It works just fine from the shell interpreter:

```auto
python
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__'/Users/natalia/Software/root/lib/ROOT.pyc'
>>>

```

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:

```auto
file:///Library/Python/2.7/site-packages/pip-6.1.1-py2.7.egg
file:///Users/natalia/Software/root/lib
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
file:///System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
file:///System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload
file:///System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
file:///Library/Python/2.7/site-packages
file:///Users/natalia/Software/root/bin
file:///Users/natalia/Software/root

```

and then I created the following file in Pycharm:

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

```

When run, it returns this:

```auto
Traceback (most recent call last):
/Users/natalia/Software:/Users/natalia/Software/root:/Users/natalia/Work/Projects/untitled
 File "/Users/natalia/Work/Projects/untitled/l.py", 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](https://mindmajix.com/python-training)

---

<div class="post-metadata">

**Author:** ![wlav](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/w/f07891/32.png) [@wlav](https://root-forum.cern.ch/u/wlav)\
**Post date:** [July 21, 2018, 4:39pm UTC](https://root-forum.cern.ch/t/pycharm-4-no-module-named-root-when-importing-a-locally-installed-module-pyroot-that-is-working-fine-from-shell-on-mac-os-x-yosemite/29898/2 "2018-07-21T16:39:42Z")

</div>

```auto
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.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [August 4, 2018, 4:39pm UTC](https://root-forum.cern.ch/t/pycharm-4-no-module-named-root-when-importing-a-locally-installed-module-pyroot-that-is-working-fine-from-shell-on-mac-os-x-yosemite/29898/3 "2018-08-04T16:39:45Z")

</div>

Closed on August 4, 2018, 4:39pm UTC

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