# How to set PYTHONPATH when I obtain "Import ROOT error . No module found"

**URL:** <https://root-forum.cern.ch/t/how-to-set-pythonpath-when-i-obtain-import-root-error-no-module-found/39763>\
**Category:** Newbie\
**Created:** [June 4, 2020, 6:56pm UTC](https://root-forum.cern.ch/t/how-to-set-pythonpath-when-i-obtain-import-root-error-no-module-found/39763 "2020-06-04T18:56:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liam\_hayden](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/ecccb3/32.png) [@Liam\_hayden](https://root-forum.cern.ch/u/Liam_hayden)\
**Post date:** [June 4, 2020, 6:56pm UTC](https://root-forum.cern.ch/t/how-to-set-pythonpath-when-i-obtain-import-root-error-no-module-found/39763/1 "2020-06-04T18:56:13Z")

</div>

* * *

\_Please read [tips for efficient and successful posting](https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292) and [posting code]([Is it possible to nest trees?](https://root-forum.cern.ch/t/posting-code-read-this-first/282)

```auto

```

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 4, 2020, 7:02pm UTC](https://root-forum.cern.ch/t/how-to-set-pythonpath-when-i-obtain-import-root-error-no-module-found/39763/2 "2020-06-04T19:02:32Z")

</div>

See if you have “pyroot” among: `root-config --features`

In principle you should not set ROOT related environment variables manually. You should simply:  
`source /full/path/to/your/root/bin/thisroot.sh`

---

<div class="post-metadata">

**Author:** ![Liam\_hayden](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/ecccb3/32.png) [@Liam\_hayden](https://root-forum.cern.ch/u/Liam_hayden)\
**Post date:** [June 4, 2020, 7:44pm UTC](https://root-forum.cern.ch/t/how-to-set-pythonpath-when-i-obtain-import-root-error-no-module-found/39763/3 "2020-06-04T19:44:09Z")

</div>

yes. i have pyroot. I actually figured it out just now . I had already done source command as you mentioned which didnt work. But when I set the correct path manually I got it.  
Thanks anyway.

---

<div class="post-metadata">

**Author:** ![amadio](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/amadio/32/12562_2.png) [@amadio](https://root-forum.cern.ch/u/amadio)\
**Post date:** [June 5, 2020, 10:20pm UTC](https://root-forum.cern.ch/t/how-to-set-pythonpath-when-i-obtain-import-root-error-no-module-found/39763/4 "2020-06-05T22:20:54Z")

</div>

```bash
export PYTHONPATH=$(root-config --libdir)

```

---

<div class="post-metadata">

**Author:** ![elonvengas](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/8dc957/32.png) [@elonvengas](https://root-forum.cern.ch/u/elonvengas)\
**Post date:** [August 17, 2021, 6:52am UTC](https://root-forum.cern.ch/t/how-to-set-pythonpath-when-i-obtain-import-root-error-no-module-found/39763/5 "2021-08-17T06:52:08Z")

</div>

Python does not add the current directory to sys.path, but rather the directory that the script is in. Add your project directory to either sys.path or $PYTHONPATH.

Also, set the PYTHONPATH to ‘.’ to solve this issue.

For a one-liner you could as easily do:

`PYTHONPATH='.' your_python_script`
