Python does not see pygraphviz

I installed pygraphviz using easy_install, but when I run python I have an error:

>>>import pygraphviz as pgv Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named pygraphviz >>> 

Using Ubuntu 12.04 and gnome-terminal.

+27
python install pygraphviz
Mar 27 '13 at 14:28
source share
6 answers

Assuming you are on Ubuntu, see the following steps.

  • sudo apt-get install graphviz libgraphviz-dev pkg-config
  • Create and activate virtualenv if necessary. The commands look something like sudo apt-get install python-pip python-virtualenv
  • Run pip install pygraphviz
  • Launch the terminal and check the import, and see if it works
+79
Mar 27 '13 at 19:40
source share

Quick and easy solution:

 sudo apt-get install -y python-pygraphviz 

using pip will also work, but make sure you already have the GUI, libgraphviz-dev, and pkg-config installed.

 sudo apt-get install -y graphviz libgraphviz-dev pkg-config python-pip sudo pip install pygraphviz 
+9
Jul 03 '13 at 19:35
source share

Ubuntu 14.04 has a problem with automatically detecting the graphviz library and including files. If you follow these steps, you will probably be safe.

 1) sudo apt-get install graphviz libgraphviz-dev pkg-config python-pip 2) pip install pygraphviz --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/" 
+9
Nov 17 '16 at 10:37
source share

On Mac OSX, the following did the trick for me:

 pip install graphviz pip install cgraph export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig cd /usr/local/include/graphviz sudo ln -s . graphviz pip install pygraphviz 

[As suggested, a fixed typo from earlier / urs / local / to / usr / local /]

+8
Oct 11 '16 at 11:35
source share

On Ubuntu 15.10+ (i.e. 2015 Debian) a quick and easy solution:

 sudo apt-get install python-pygraphviz 

Any dependencies get pulled correctly with apt.

+1
Mar 22 '16 at 20:03
source share

Bart Theeten works on Mac OSX El Capitan, but there are two things you need to be careful about. First, make sure you install graphviz on your computer. You can use homegrown:

 brew install graphviz 

Another thing is that you add the package path to PYTHONPATH

 export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages/ 
+1
Nov 15 '16 at 4:41
source share



All Articles