pipdeptree icon indicating copy to clipboard operation
pipdeptree copied to clipboard

graphviz is not available, but necessary for the output option. Please install it.

Open natea opened this issue 6 years ago • 11 comments

When I try to run pipdeptree with output of png, svg or pdf, it tells me that Graphviz is not installed, but it appears to be already installed.

root@8bf322acc378:/edx/app/edxapp/edx-platform# pipdeptree --graph-output png > pipdeps.png
graphviz is not available, but necessary for the output option. Please install it.

root@8bf322acc378:/edx/app/edxapp/edx-platform# apt-get install graphviz
Reading package lists... Done
Building dependency tree
Reading state information... Done
graphviz is already the newest version (2.38.0-12ubuntu2.1).
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.

root@8bf322acc378:/edx/app/edxapp/edx-platform# pipdeptree --graph-output png > pipdeps.png
graphviz is not available, but necessary for the output option. Please install it.

natea avatar Aug 13 '17 06:08 natea

Is the Python interface for graphviz installed? - https://pypi.python.org/pypi/graphviz

naiquevin avatar Aug 13 '17 12:08 naiquevin

pip install graphviz fixed this for me. Perhaps you should add this information to the error message.

beruic avatar Jan 12 '18 09:01 beruic

Have you thought about adding it as an extra dependency (extras_require) in your setup.py?

ezdac avatar Mar 09 '18 13:03 ezdac

I have thought about this and I think it would be better to keep it optional. Firstly, the functionality to output the dependency tree as a graph is optional. And even if the python lib is added as a dependency, it will not work unless the Graphviz package is also installed on the machine which is something that's outside the scope of pip.

naiquevin avatar Mar 09 '18 14:03 naiquevin

So perhaps the error message should tell you to install both graphviz and the python package?

beruic avatar Apr 16 '18 14:04 beruic

It does fail with the following,

graphviz is not available, but necessary for the output option. Please install it.

I don't think this tool should should tell the users how to install it. Graphviz's docs should take care of that.

I do agree that it would be a good idea to mention in the README that installation of both graphviz and the python interface will be needed if someone wants to use the --graph-output option.

naiquevin avatar Apr 16 '18 14:04 naiquevin

@beruic Fair point actually. The error just says install graphviz so one is more likely to think about the graphviz executable and not the python interface. Don't mind rewording the error message, just want to make sure it's short and concise. Will do this change in the next release.

naiquevin avatar Apr 16 '18 14:04 naiquevin

Unfortunately the python interface does not complain about the binaries missing when it is installed. Otherwise it would be enough to complain about the missing interface.

Can you easily detect whether the binaries are missing without the interface? Otherwise, perhaps you should just complain about the missing interface first, and then about the binaries when it is detected that they are missing through the interface.

beruic avatar Apr 18 '18 09:04 beruic

First improvement, don't eat the diagnostics, and be explicit…

--- a/pipdeptree.py
+++ b/pipdeptree.py
@@ -405,9 +405,9 @@ def dump_graphviz(tree, output_format='dot'):
     """
     try:
         from graphviz import backend, Digraph
-    except ImportError:
+    except ImportError as cause:
         print('graphviz is not available, but necessary for the output '
-              'option. Please install it.', file=sys.stderr)
+              'option. Please call `pip install "pipdeptree[graphviz]"`. [{}]'.format(cause), file=sys.stderr)
         sys.exit(1)
 
     if output_format not in backend.FORMATS:

jhermann avatar Jun 20 '18 13:06 jhermann

Hey,

whats the status of this enhancement? I took me today a bit of searching and headscratching, because graphviz itself was already installed, before finding this thread.

staeff avatar Nov 15 '20 15:11 staeff

Planning to specify graphviz as an extra dependency in setup.py in the next release.

naiquevin avatar Dec 20 '20 08:12 naiquevin

This was done.

gaborbernat avatar Sep 06 '22 07:09 gaborbernat