Cannot import conda-installed package after carefully following Troubleshooting guide

0 views
Skip to first unread message

Erick Matsen

unread,
Jul 14, 2017, 11:14:57 AM7/14/17
to conda - Public
Hello everyone--


I'm dumbfounded that after following the instructions carefully in https://conda.io/docs/troubleshooting.html#conda-claims-installed that I still can't import a conda-installed package.

Here's my sad tale. Any help would be much much appreciated!

Thank you!


I. Make sure you are in the same conda environment as your package

(cft) stoat ~ » python -c "import sys; print(sys.prefix)"             
/home/matsen/anaconda2/envs/cft


II. For Python packages, make sure you have not set the PYTHONPATH or PYTHONHOME variable

(cft) stoat ~ » conda info -a | grep PYTHON
PYTHONHOME: <not set>
PYTHONPATH: <not set>


III. For Python packages, remove any site-specific directories

(cft) stoat ~ » tree ~/.local
/home/matsen/.local
└── share
    └── autojump
        ├── autojump_errors
        ├── autojump.txt
        └── autojump.txt.bak

2 directories, 3 files

but perhaps more importantly:

(cft) stoat ~ » python -c "import sys; print(sys.path)" | sed "s/ /\n/g"
['',
'/home/matsen/anaconda2/envs/cft/lib/python27.zip',
'/home/matsen/anaconda2/envs/cft/lib/python2.7',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/plat-linux2',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/lib-tk',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/lib-old',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/lib-dynload',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/site-packages',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/site-packages/DendroPy-4.2.0-py2.7.egg',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/site-packages/ete3-3.0.0b36-py3.5.egg',
'/home/matsen/anaconda2/envs/cft/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg']


IV. For C libraries, unset the environment variables LD_LIBRARY_PATH on Linux

Not that this should matter in my case, but for good measure:

(cft) stoat ~ » conda info -a | grep LD    
LD_LIBRARY_PATH: <not set>


V. Occasionally, an installed package will become corrupted

(cft) stoat ~ » conda install -f graphviz                                                                                                                                                                       1 ↵
Fetching package metadata .........
Solving package specifications: .

Package plan for installation in environment /home/matsen/anaconda2/envs/cft:

The following NEW packages will be INSTALLED:

    graphviz: 2.38.0-5

Proceed ([y]/n)? y


And yet still...

(cft) stoat ~ » python -c "import graphviz"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named graphviz


Now, for the kicker

I poked around in site-packages and didn't see graphviz there. So I pip installed it, it showed up, and now I can import it. On the other hand, another package biopython (which I installed with conda) is there, but I can't import it. But for the final very confusing thing:

(cft) stoat python2.7/site-packages » pip install biopython                                                                                                                                                     1 ↵
Requirement already satisfied: biopython in /home/matsen/anaconda2/envs/cft/lib/python2.7/site-packages

Lori Burns

unread,
Jul 14, 2017, 1:56:27 PM7/14/17
to conda - Public
I believe I encountered this once, and the problem is oddly named packages. If I recall correctly, "graphviz" is the compiled backend and "pygraphviz" or "python-graphviz" is the python wrapping that will allow you to "import graphviz". I suspect that "conda install graphviz python-graphviz -c conda-forge" will get you what you want.

Erick Matsen

unread,
Jul 14, 2017, 8:29:10 PM7/14/17
to conda - Public
Lori--

Thank you, thank you, thank you. 

Indeed, I needed to install python-graphviz (which is equivalent to pip installing graphviz). 

All working great now.

Erick
Reply all
Reply to author
Forward
0 new messages