# Error in installing ROOT in conda environment for python 2.7: Failed to import libcppyy

**URL:** <https://root-forum.cern.ch/t/error-in-installing-root-in-conda-environment-for-python-2-7-failed-to-import-libcppyy/50194>\
**Category:** Newbie\
**Created:** [May 31, 2022, 11:33am UTC](https://root-forum.cern.ch/t/error-in-installing-root-in-conda-environment-for-python-2-7-failed-to-import-libcppyy/50194 "2022-05-31T11:33:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike\_f](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@mike\_f](https://root-forum.cern.ch/u/mike_f)\
**Post date:** [May 31, 2022, 11:33am UTC](https://root-forum.cern.ch/t/error-in-installing-root-in-conda-environment-for-python-2-7-failed-to-import-libcppyy/50194/1 "2022-05-31T11:33:40Z")

</div>

_ROOT Version:_ 6.22.0  
_Platform:_ Mac 11.4  
Python2.7

Hello!

Sorry if I am not expressing myself in the correct jargon, but I am fairly new with these topics.

I have ROOT already running on my local machine, now I am working inside an Anaconda environment with Python 2.7. When setting up the environment I directly installed ROOT version 6.22 (compatible with Python 2.7) - it is also listed with  
`conda list root`

However when wanting to import ROOT inside python, I am getting the following error message:

“Traceback (most recent call last):  
File “”, line 1, in  
File “/Users/FranzkeMM/root\_v6.26.00/lib/ROOT/ **init**.py”, line 22, in  
import cppyy  
File “/Users/FranzkeMM/root\_v6.26.00/lib/cppyy/ **init**.py”, line 64, in  
libcppyy\_mod\_name, major, minor))  
ImportError: Failed to import libcppyy2\_7. Please check that ROOT has been built for Python 2.7”

so it seems, that python somehow looks for root on the version that is locally installed and not via Anaconda.

So my idea would have been to prevent this with sourcing like this:

`source ~/opt/anaconda3/pkgs/root-binaries-6.22.0-py27hdf2d85e_2/bin/thisroot.sh`

But the message is being returned:  
" ERROR: thisroot.sh, thisroot.csh and thisroot.fish should never be used

Look at using “conda activate ENVIRONMENT\_NAME”

Any ideas on what is happening? Thanks a lot in advance!

P.S. when sourcing to the thisroot.sh file of the locally installed root, it is working, but this is in general not what I want of course

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [May 31, 2022, 12:14pm UTC](https://root-forum.cern.ch/t/error-in-installing-root-in-conda-environment-for-python-2-7-failed-to-import-libcppyy/50194/2 "2022-05-31T12:14:33Z")

</div>

Hi @mike_f ,  
checking the obvious first, did you run `conda activate yourenvironmentname` before starting python? (EDIT: in a terminal where you did _not_ `source /Users/FranzkeMM/root_v6.26.00/bin/thisroot.sh` first?)

If you have a `source .../thisroot.sh` line in your bashrc or `.profile` you should also remove it.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![mike\_f](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@mike\_f](https://root-forum.cern.ch/u/mike_f)\
**Post date:** [May 31, 2022, 4:40pm UTC](https://root-forum.cern.ch/t/error-in-installing-root-in-conda-environment-for-python-2-7-failed-to-import-libcppyy/50194/3 "2022-05-31T16:40:06Z")

</div>

Thanks eguiraud for the reply!

I was working inside the environment, but indeed I didn’t think about the bash\_profile…

So thanks for pointing this out and sorry for bothering you with this

Cheers,  
Michael
