127

Just installed a package through anaconda (conda install graphviz), but ipython wouldn't find it.

I can see a graphviz folder in C:\Users\username\Anaconda\pkgs

But there's nothing in: C:\Users\username\Anaconda\Lib\site-packages

still wouldn't work

Chris Tang
  • 567
  • 7
  • 18
nivniv
  • 3,421
  • 5
  • 33
  • 40
  • 27
    The key to understanding is that `conda install graphviz` does not do the same thing as `pip install graphviz`. `conda install python-graphviz` does. `conda install graphviz` installs the binaries, which is the same as downloading and installing GraphViz from their website. – endolith Nov 24 '18 at 19:17
  • 2
    @endolith Thank you, thank you, thank you. – AturSams May 10 '19 at 14:09

15 Answers15

193

The graphviz conda package is no Python package. It simply puts the graphviz files into your virtual env's Library/ directory. Look e.g. for dot.exe in the Library/bin/ directory.

To install the graphviz Python package, you can use pip: conda install pip and pip install graphviz.

Always prefer conda packages if they are available over pip packages. Search for the package you need (conda search pkgxy) and then install it (conda install pkgxy). If it is not available, you can always build your own conda packages or you can try anaconda.org for user-built packages.

Update Nov 25, 2018: There exists now a python-graphviz package at Anaconda.org which contains the Python interface for the graphviz tool. Simply install it with conda install python-graphviz.
(Thanks to wedran and g-kaklam for posting this solution and to endolith for notifying me).

Update May 26, 2022: According to the pygraphviz website, the conda-forge channel should be used: conda install -c conda-forge pygraphviz (thanks to ian-thompson)

Wolfgang Ulmer
  • 3,450
  • 2
  • 21
  • 13
  • 1
    How do I install the graphviz python package then? (this one https://pypi.python.org/pypi/graphviz) I thought the "conda install" was equivalent to "pip install", I'm new to anaconda though. – nivniv Oct 30 '15 at 16:25
  • 3
    You can try to `conda install pip` and `pip install graphviz`. – Wolfgang Ulmer Nov 02 '15 at 08:48
  • 7
    Doesn't it defeat the purpose of using anaconda for installing python packages? or is it not its intended purpose in the first place? – nivniv Nov 02 '15 at 19:51
  • 2
    Always prefer conda packages *if they are available* over pip packages. You can always build your own conda packages or you can try http://anaconda.org/ for user-built packages. – Wolfgang Ulmer Nov 03 '15 at 08:00
  • @WolfgangUlmer your comment should be the answer – Julie May 20 '16 at 20:51
  • This answer helps to resolve some of the confusion I am having. But I am trying to install pygraphvis (which is needed to use the `graphviz_layout` method of NetworkX). So what is the difference between pygraphvis and the graphviz python package? Presumably they are not the same thing. – Bill Oct 19 '16 at 02:54
  • @WolfgangUlmer just though I'd give a shout out to you for the use conda over pip packages. Wasted so much time until I realized that :/ – Scott G Jan 23 '18 at 20:18
  • 4
    `Always prefer conda packages if they are available over pip packages` Yes, so don't follow this answer. Follow wedran's answer of `conda install python-graphviz` instead. – endolith Nov 24 '18 at 19:19
  • the pygraphviz site recommends installing from the `conda-forge` channel [source](https://pygraphviz.github.io/documentation/stable/install.html) – Ian Thompson May 24 '22 at 20:24
127

On conda:

First install

conda install graphviz

Then the python-library for graphviz python-graphviz

gv_python is a dynamically loaded extension for python that provides access to the graph facilities of graphviz.

conda install python-graphviz

There is also pydot package, which can parse and dump into DOT language, used by GraphViz

conda install pydot
monolith
  • 1,606
  • 1
  • 12
  • 21
  • 5
    this is a conda only solution, no pip needed. I like that – Goosebumps Feb 08 '18 at 10:38
  • 3
    Now how did you come to know about this additional requirement i.e. 'python-graphviz' package and why didn't anaconda mark this as a dependency in first place? – Thirsty_Crow Jun 09 '18 at 13:40
  • 1
    I still get ```OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.``` – endolith Jul 29 '18 at 13:54
  • 1
    Aha! `conda install python-graphviz` does the same thing as `pip install graphviz`. while `conda install graphviz` does the same thing as downloading binaries from the GraphViz website. – endolith Nov 24 '18 at 19:16
18

for me the problem was solved by installing another supportive package.

so I installed graphviz package through anaconda then I failed to import it

after that I installed a second package named python-graphviz also through anaconda

then I succeeded in importing graphviz module into my code

I hope this will help someone :)

stackunderflow
  • 3,811
  • 5
  • 31
  • 43
12

You can actually install both packages at the same time. For me:

conda install -c anaconda graphviz python-graphviz

did the trick.

gekaklam
  • 331
  • 2
  • 5
8

To install graphviz,

conda install -c anaconda graphviz
pip install graphviz

If conda command not found. Follow these:

export PATH=~/anaconda/bin:$PATH
conda --version # to check your conda version

Difference between conda and pip installation,
refer this stackoverflow answer

Mukul Aggarwal
  • 1,515
  • 20
  • 16
3

I have followed the following steps and it worked fine for me.

1 . Download and install graphviz-2.38.msi from https://graphviz.gitlab.io/_pages/Download/Download_windows.html

2 . Set the path variable

(a) Control Panel > System and Security > System > Advanced System Settings >  Environment Variables > Path > Edit

(b) add 'C:\Program Files (x86)\Graphviz2.38\bin'
  • This solution worked for me in trying to get `bprofile` installed on Windows, as it only searches in `Program Files` and `Program Files (x86)` for an installed graphviz/`dot.exe` and fails to find it if it's installed anywhere else. – vab Jan 20 '19 at 05:01
2

Graphviz is evidently included in Anaconda so as to be used with pydot or pydot-ng (both of which are included in Anaconda). You may want to consider using one of those instead of the 'graphviz' Python module.

2

For ubuntu users I recommend this way:

sudo apt-get install -y graphviz libgraphviz-dev
Vadim
  • 4,219
  • 1
  • 29
  • 44
2

Remeber! If you are using jupyter notebook, please restart it after the installing. That's work for me.

Because the condition before is a static variate as below:

enter image description here

enter image description here

enter image description here

סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
2

Check if tensorflow is activated in your terminal

first deactivate it using

conda deactivate

then use the command

conda install python-graphviz

and then install

conda install graphviz

this is solution for UBUNTU USERS :) CHEERS :)

AR N
  • 21
  • 1
1

This command works officially for python:

conda install -c conda-forge python-graphviz
Mohammad Heydari
  • 3,933
  • 2
  • 26
  • 33
1

run this: conda install python-graphviz

Kai Wang
  • 3,303
  • 1
  • 31
  • 27
0

I am using anaconda for the same.

I installed graphviz using conda install graphviz in anaconda prompt. and then installed pip install graphviz in the same command prompt. It worked for me.

Chris Tang
  • 567
  • 7
  • 18
0

I tried this way and worked for me.

conda install -c anaconda graphviz
pip install graphviz
Hafez Ahmad
  • 175
  • 2
  • 7
0

Thank you to everyone - this really helped me.

The following combination seemed to be enough (Macbook Pro M1; Monterey; Anaconda):

conda install -c anaconda graphviz \
conda install -c anaconda pydot \
conda install -c anaconda python-graphviz
sakurashinken
  • 3,940
  • 8
  • 34
  • 67