Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphviz cgraph.h not found #155

Closed
parthi2929 opened this issue May 7, 2018 · 47 comments
Closed

Graphviz cgraph.h not found #155

parthi2929 opened this issue May 7, 2018 · 47 comments
Milestone

Comments

@parthi2929
Copy link

Hi

I tried installing pygraphviz with below command and different variations but all in vain

pip install pygraphviz --install-option="--include-path=C:\Program Files (x86)\Graphviz2.38\include\graphviz" --install-option="--library-path=C:\Program Files (x86)\Graphviz2.38\lib" 

Error:

pygraphviz/graphviz_wrap.c(2954): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2

Kindly help

@SaintNazaire
Copy link

Reproduced the error independently.
Clearly c_graph.h header file missing.
@hagberg, @mmarkov do you have copy of it?
Any information as to portability to Python 3.6?

@parthi2929
Copy link
Author

The cgraph files is available in the path mentioned.
also note that, installed graphviz is x86 (which is only officially available).

@SaintNazaire
Copy link

@parthi2929, sorry bu the cgraph.h file isn't available on my end.
Could you let me know in which folder you found it?
Roger on x86.

@parthi2929
Copy link
Author

you could find it here
C:\Program Files (x86)\Graphviz2.38\include\graphviz

@Frackup
Copy link

Frackup commented Sep 20, 2018

Hi,
Same issue for me. I tried all I could find through the web (and I checked many threads about that problem).
I tried installing pygraphviz through pip (not working, same issue),
python -m pip install --global-option=build_ext --global-option="-IC:\Program Files (x86)\Graphviz2.38\include" --global-option="-LC:\Program Files (x86)\Graphviz2.38\lib\release\lib" pygraphviz

tried donwloading it and installing it (not working).
python setup.py install --include-path="C:\Program Files (x86)\Graphviz2.38\include\graphviz" --library-path="C:\Program Files (x86)\Graphviz2.38\lib\release\lib"

Tried also to modify the files as mentionned here (not working, same issue).

I tried downloading and replacing files in graphviz (not pygraphviz) with a x64 version (not working).

As mentionned by Parthi2929, the file is present in the include folder

This issue is making me slightly mad, please help :).

@tribbloid
Copy link

tribbloid commented Feb 7, 2019

also affects me (except that I'm using Ubuntu 18.04 + virtualenv, with graphviz already installed):

$ pip install pygraphviz
Collecting pygraphviz
  Using cached https://files.pythonhosted.org/packages/7e/b1/d6d849ddaf6f11036f9980d433f383d4c13d1ebcfc3cd09bc845bda7e433/pygraphviz-1.5.zip
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... error
    Complete output from command /home/peng/git/convnet-abstraction/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-_7wwjl1o/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-xl7438zl/install-record.txt --single-version-externally-managed --compile --install-headers /home/peng/git/convnet-abstraction/venv/include/site/python3.6/pygraphviz:
    running install
    Trying dpkg
    include_dirs=None
    library_dirs=/usr/lib/python3/dist-packages/pygraphviz
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/pygraphviz
    copying pygraphviz/agraph.py -> build/lib.linux-x86_64-3.6/pygraphviz
    copying pygraphviz/graphviz.py -> build/lib.linux-x86_64-3.6/pygraphviz
    copying pygraphviz/version.py -> build/lib.linux-x86_64-3.6/pygraphviz
    copying pygraphviz/__init__.py -> build/lib.linux-x86_64-3.6/pygraphviz
    copying pygraphviz/release.py -> build/lib.linux-x86_64-3.6/pygraphviz
    creating build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_unicode.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_drawing.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_node_attributes.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_setup.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_attributes.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_string.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_graph.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_subgraph.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_clear.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_layout.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_html.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_readwrite.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/__init__.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    copying pygraphviz/tests/test_edge_attributes.py -> build/lib.linux-x86_64-3.6/pygraphviz/tests
    running egg_info
    writing pygraphviz.egg-info/PKG-INFO
    writing dependency_links to pygraphviz.egg-info/dependency_links.txt
    writing top-level names to pygraphviz.egg-info/top_level.txt
    reading manifest file 'pygraphviz.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '*.png' under directory 'doc'
    warning: no files found matching '*.html' under directory 'doc'
    warning: no files found matching '*.txt' under directory 'doc'
    warning: no files found matching '*.css' under directory 'doc'
    warning: no previously-included files matching '*~' found anywhere in distribution
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '.svn' found anywhere in distribution
    no previously-included directories found matching 'doc/build'
    writing manifest file 'pygraphviz.egg-info/SOURCES.txt'
    copying pygraphviz/graphviz.i -> build/lib.linux-x86_64-3.6/pygraphviz
    copying pygraphviz/graphviz_wrap.c -> build/lib.linux-x86_64-3.6/pygraphviz
    running build_ext
    building 'pygraphviz._graphviz' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/pygraphviz
    gcc -pthread -B /home/shared/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/peng/git/convnet-abstraction/venv/include -I/home/shared/anaconda3/include/python3.6m -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-3.6/pygraphviz/graphviz_wrap.o
    pygraphviz/graphviz_wrap.c:2987:10: fatal error: graphviz/cgraph.h: No such file or directory
     #include "graphviz/cgraph.h"
              ^~~~~~~~~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    
    ----------------------------------------
Command "/home/peng/git/convnet-abstraction/venv/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-_7wwjl1o/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-xl7438zl/install-record.txt --single-version-externally-managed --compile --install-headers /home/peng/git/convnet-abstraction/venv/include/site/python3.6/pygraphviz" failed with error code 1 in /tmp/pip-install-_7wwjl1o/pygraphviz/

@kitaev-chen
Copy link

conda install pygraphviz might be easier

@tan-wei
Copy link

tan-wei commented Apr 22, 2019

The same for me. Clearly, I have told python setup.py install --include-path="C:\Program Files (x86)\Graphviz2.38\include\", however, it still complains that "Cannot open include file: 'graphviz/cgraph.h'".

@tom-rethink
Copy link

tom-rethink commented May 17, 2019

To install on ubuntu 18.04, I had to also install graphviz-dev: sudo apt install graphviz-dev

@shoeffner
Copy link

I had the same problem (MacOS). To resolve it, just copy the files from /include/graphviz to /include/graphviz/graphviz. Should work on all systems like that.

The problem is, that the graphviz directory is searched for a file with the pattern graphviz/cgraph.h, but there is only cgraph.h, so adding an additional directory resolves it.

An alternative solution is to set the -I flag properly (i.e. removing the graphviz there), but I didn't dive into that.

@Khris777
Copy link

Same problem here on Windows 10 on anaconda/conda using pip.

After I added C:\Program Files (x86)\Graphviz2.38\include\graphviz into my PATH the installation succeeded in the anaconda root environment, but I can't get it to install into another conda virtual environment, it always throws the same error that it can't find its includes. When I echo the PATH variable inside of the activated environment everything is there and it should be able to locate the files.

I also added C:\Program Files (x86)\Graphviz2.38\include into my PATH as well to no avail.

And pygraphviz is not on conda, at least not in the common channels.

@willismonroe
Copy link

willismonroe commented Sep 9, 2019

Ubuntu 19.04 here, had to run:
sudo apt install libgraphviz-dev

@rastaxe
Copy link

rastaxe commented Oct 14, 2019

I had to install also python3.7-dev

@litchfield
Copy link

litchfield commented Nov 11, 2019

Quick fix for Mac OSX + homebrew graphviz --

pip install --install-option="--include-path=/usr/local/include/" --install-option="--library-path=/usr/local/lib/" pygraphviz

@ubiq-x
Copy link

ubiq-x commented Feb 11, 2020

This has worked for me on a MacOS Catalina with HomeBrew 2.2.5:

pip install pygraphviz --install-option="--include-path=/usr/local/Cellar/graphviz/2.42.2/include" --install-option="--library-path=/usr/local/Cellar/graphviz/2.42.2/lib"

@setarehz
Copy link

Windows 10

I had the same problem with Windows 10
Also, I installed GraphViz2.38 manually, but it didn't work.
PyGraphviz 1.5 is a build on the Anaconda channel for Windows 64 bit running Python 3.6, Python 3.7 or Python 3.8. If you're running Anaconda, you can install it with:
conda install -c alubbock pygraphviz

the ref is: here

It worked for me

@jarrodmillman jarrodmillman added this to the 1.7 milestone Dec 25, 2020
dhimmel added a commit to related-sciences/nxontology that referenced this issue Jan 5, 2021
@Gabri-TeamSight
Copy link

I had the same problem (MacOS). To resolve it, just copy the files from /include/graphviz to /include/graphviz/graphviz. Should work on all systems like that.

The problem is, that the graphviz directory is searched for a file with the pattern graphviz/cgraph.h, but there is only cgraph.h, so adding an additional directory resolves it.

An alternative solution is to set the -I flag properly (i.e. removing the graphviz there), but I didn't dive into that.

Hi, I have MacOs BigSur on MacBook Air ARM M1, I have the same issue with pzgraphviz 2.44.1
I think your contrite better the point as from the log the gcc compiler cannot find Graphviz/cgraph.h, so I created another directory called graphviz inside the directory include/graphviz where I copied all the files in the upper-directory, including cgraph.h, but again the same issues appears. I tried all the other Mac work-around here but nothing worked... Any help? Thanks

Here's the log:

Installing collected packages: pygraphviz Running setup.py install for pygraphviz ... error ERROR: Command errored out with exit status 1: command: /Users/gabrielevolpi/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/mq/s1y1l_617z9181khd2q83wlw0000gn/T/pip-install-fgaoghun/pygraphviz/setup.py'"'"'; __file__='"'"'/private/var/folders/mq/s1y1l_617z9181khd2q83wlw0000gn/T/pip-install-fgaoghun/pygraphviz/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/mq/s1y1l_617z9181khd2q83wlw0000gn/T/pip-record-txxowdye/install-record.txt --single-version-externally-managed --compile --install-headers /Users/gabrielevolpi/anaconda3/include/python3.8/pygraphviz cwd: /private/var/folders/mq/s1y1l_617z9181khd2q83wlw0000gn/T/pip-install-fgaoghun/pygraphviz/ Complete output (61 lines): running install Trying dpkg Failed to find dpkg Trying pkg-config include_dirs=/opt/homebrew/Cellar/graphviz/2.44.1/include/graphviz:/opt/homebrew/Cellar/graphviz/2.44.1/include library_dirs=/opt/homebrew/Cellar/graphviz/2.44.1/lib running build running build_py creating build creating build/lib.macosx-10.9-x86_64-3.8 creating build/lib.macosx-10.9-x86_64-3.8/pygraphviz copying pygraphviz/release.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz copying pygraphviz/version.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz copying pygraphviz/graphviz.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz copying pygraphviz/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz copying pygraphviz/agraph.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz creating build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_setup.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_string.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_html.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_close.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_clear.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_layout.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_graph.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests copying pygraphviz/tests/test_attributes.py -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz/tests running egg_info writing pygraphviz.egg-info/PKG-INFO writing dependency_links to pygraphviz.egg-info/dependency_links.txt writing top-level names to pygraphviz.egg-info/top_level.txt reading manifest file 'pygraphviz.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching '*.png' under directory 'doc' warning: no files found matching '*.html' under directory 'doc' warning: no files found matching '*.txt' under directory 'doc' warning: no files found matching '*.css' under directory 'doc' warning: no previously-included files matching '*~' found anywhere in distribution warning: no previously-included files matching '*.pyc' found anywhere in distribution warning: no previously-included files matching '.svn' found anywhere in distribution no previously-included directories found matching 'doc/build' writing manifest file 'pygraphviz.egg-info/SOURCES.txt' copying pygraphviz/graphviz.i -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-10.9-x86_64-3.8/pygraphviz running build_ext building 'pygraphviz._graphviz' extension creating build/temp.macosx-10.9-x86_64-3.8 creating build/temp.macosx-10.9-x86_64-3.8/pygraphviz gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/gabrielevolpi/anaconda3/include -arch x86_64 -I/Users/gabrielevolpi/anaconda3/include -arch x86_64 -I/opt/homebrew/Cellar/graphviz/2.44.1/include/graphviz:/opt/homebrew/Cellar/graphviz/2.44.1/include -I/Users/gabrielevolpi/anaconda3/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.9-x86_64-3.8/pygraphviz/graphviz_wrap.o pygraphviz/graphviz_wrap.c:2676:10: fatal error: 'graphviz/cgraph.h' file not found #include "graphviz/cgraph.h" ^~~~~~~~~~~~~~~~~~~ 1 error generated. error: command 'gcc' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /Users/gabrielevolpi/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/mq/s1y1l_617z9181khd2q83wlw0000gn/T/pip-install-fgaoghun/pygraphviz/setup.py'"'"'; __file__='"'"'/private/var/folders/mq/s1y1l_617z9181khd2q83wlw0000gn/T/pip-install-fgaoghun/pygraphviz/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/mq/s1y1l_617z9181khd2q83wlw0000gn/T/pip-record-txxowdye/install-record.txt --single-version-externally-managed --compile --install-headers /Users/gabrielevolpi/anaconda3/include/python3.8/pygraphviz Check the logs for full command output.

@shoeffner
Copy link

It seems you are using anaconda, can you try conda install pygraphviz?

If not, have you tried adjusting the paths to your brew installation?

$ pip install --install-option="--include-path=$(brew --prefix graphviz)/include" --install-option="--library-path=$(brew --prefix graphviz)/lib" pygraphviz

Alternatively, please double-check your paths and report back to us – your log mentions /opt/homebrew/Cellar/graphviz/2.44.1/, but at least on my system homebrew installs stuff to /usr/local/Cellar/graphviz/2.44.1/.

@Gabri-TeamSight
Copy link

It seems you are using anaconda, can you try conda install pygraphviz?

If not, have you tried adjusting the paths to your brew installation?

$ pip install --install-option="--include-path=$(brew --prefix graphviz)/include" --install-option="--library-path=$(brew --prefix graphviz)/lib" pygraphviz

Alternatively, please double-check your paths and report back to us – your log mentions /opt/homebrew/Cellar/graphviz/2.44.1/, but at least on my system homebrew installs stuff to /usr/local/Cellar/graphviz/2.44.1/.

Hi, thank you for your help.

I tried with Honda but it seems it doesn't allow me to install with because of my python version (Do you confirm pygraphviz doesn't support python 3.8?):

(base) gabrielevolpi@Air-di-Gabriele NetworkAnalysis %  conda install pygraphviz
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \ 
Found conflicts! Looking for incompatible packages.
This can take several minutes.  Press CTRL-C to abort.
failed                                                                                                                                                                                                    

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

  - pygraphviz -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']

Your python: python=3.8

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

Using instead the adjusted paths of brew with pip seemed work:

(base) gabrielevolpi@Air-di-Gabriele NetworkAnalysis % pip install --install-option="--include-path=$(brew --prefix graphviz)/include" --install-option="--library-path=$(brew --prefix graphviz)/lib" pygraphviz
/Users/gabrielevolpi/anaconda3/lib/python3.8/site-packages/pip/_internal/commands/install.py:235: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
  cmdoptions.check_install_build_global(options)
Collecting pygraphviz
  Using cached pygraphviz-1.6.zip (117 kB)
Skipping wheel build for pygraphviz, due to binaries being disabled for it.
Installing collected packages: pygraphviz
    Running setup.py install for pygraphviz ... done
Successfully installed pygraphviz-1.6

but than it raises me error when I try to import the library in python;

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-44-e9ec173dab0d> in <module>
----> 1 import pygraphviz

~/anaconda3/lib/python3.8/site-packages/pygraphviz/__init__.py in <module>
     54 __license__ = release.license
     55 
---> 56 from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute, DotError
     57 
     58 __all__ = ["AGraph", "Node", "Edge", "Attribute", "ItemAttribute", "DotError"]

~/anaconda3/lib/python3.8/site-packages/pygraphviz/agraph.py in <module>
     18 from collections.abc import MutableMapping
     19 
---> 20 from . import graphviz as gv
     21 
     22 _DEFAULT_ENCODING = "UTF-8"

~/anaconda3/lib/python3.8/site-packages/pygraphviz/graphviz.py in <module>
     11 # Import the low-level C/C++ module
     12 if __package__ or "." in __name__:
---> 13     from . import _graphviz
     14 else:
     15     import _graphviz

ImportError: dlopen(/Users/gabrielevolpi/anaconda3/lib/python3.8/site-packages/pygraphviz/_graphviz.cpython-38-darwin.so, 2): Symbol not found: _Agdirected
  Referenced from: /Users/gabrielevolpi/anaconda3/lib/python3.8/site-packages/pygraphviz/_graphviz.cpython-38-darwin.so
  Expected in: flat namespace
 in /Users/gabrielevolpi/anaconda3/lib/python3.8/site-packages/pygraphviz/_graphviz.cpython-38-darwin.so

It is pheraps connected to my incompatible version of Python?
Thank you again

@rossbar
Copy link
Contributor

rossbar commented Jan 14, 2021

There is a release candidate (1.7rc1) out now that tries to address some of these issues. If you are on a mac and have installed Graphviz with homebrew, then installation of pygraphviz should work out-of-the-box. You can try the pre-release with pip: pip install --pre pygraphviz==1.7rc1.

The install instructions for macOS have also been updated to provide recipes that should work for users who have installed Graphviz via macports as well.

@jarrodmillman jarrodmillman modified the milestones: 1.7, 1.8 Feb 1, 2021
@rossbar
Copy link
Contributor

rossbar commented Feb 2, 2021

Pygraphviz 1.7 has been released which includes and updated installation procedures for installing on all platforms including Windows and macOS. Please see the updated installation guide for details on your specific platform. If you are still having problems or your use-case is not covered in the documentation, please open a new issue with info about your platform and how Graphviz was installed.

@rossbar rossbar closed this as completed Feb 2, 2021
@mahoriES
Copy link

mahoriES commented May 19, 2021

Ubuntu 20 here.

This worked for me

sudo apt install libgraphviz-dev

@JonasFreireAlcantara
Copy link

Ubuntu 20 here.

This worked for me

sudo apt install libgraphviz-dev

Thank you guy, it worked for me too, Ubuntu 20.04.

@isaquebc
Copy link

isaquebc commented Jan 10, 2022

On mac osx M1

I just did

brew install graphviz

@dp1889
Copy link

dp1889 commented Apr 23, 2022

This worked for me (Mac OS ver 12.3.1, homebrew 3.4.7, homebrew graphviz 3.0.0)
pip3 install --global-option=build_ext --global-option="-I$(brew --prefix graphviz)/include" --global-option="-L$(brew --prefix graphviz)/lib" pygraphviz

@smoquet
Copy link

smoquet commented May 4, 2022

this was the final straw: sudo apt-get install python3.6-dev

@HHMathewChan
Copy link

It seems you are using anaconda, can you try conda install pygraphviz?

If not, have you tried adjusting the paths to your brew installation?

$ pip install --install-option="--include-path=$(brew --prefix graphviz)/include" --install-option="--library-path=$(brew --prefix graphviz)/lib" pygraphviz

Alternatively, please double-check your paths and report back to us – your log mentions /opt/homebrew/Cellar/graphviz/2.44.1/, but at least on my system homebrew installs stuff to /usr/local/Cellar/graphviz/2.44.1/.

Thx your command work for me as well

@fzy3232
Copy link

fzy3232 commented Aug 19, 2022

On Ubuntu, use this:

sudo apt-get install python3-pygraphviz

@Josha91
Copy link

Josha91 commented Sep 19, 2022

I'm getting this same error, but on SUSE. None of the solutions above has worked for me (so far). I installed graphviz with zypper, but still get the same error.

@rsha256
Copy link

rsha256 commented Feb 25, 2023

Is there a solution that uses just pip (for if you are working on a remote Linux environment which does not have apt nor brew)?

@rossbar
Copy link
Contributor

rossbar commented Feb 25, 2023

Is there a solution that uses just pip (for if you are working on a remote Linux environment which does not have apt nor brew)?

Unfortunately, no. graphviz must be installed on the system in order to install pygraphviz. There are complicated reasons for this (see e.g. #167).

@mmarkov
Copy link
Contributor

mmarkov commented Feb 27, 2023

pygraphviz is not a python native implementation, internally it uses C based implementation of graphviz and trying to expose as much functionality as possible, but actual heavy lifting of generating images from graph definition is still done by graphviz application.

@rjudet
Copy link

rjudet commented Mar 30, 2023

I was running into pretty much the same issue on RHEL with Python 3.8 few days ago, getting:

running build_ext
building 'pygraphviz._graphviz' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/pygraphviz
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/opt/rh/rh-python38/root/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DSWIG_PYTHON_STRICT_BYTE_CHAR -I/opt/rh/rh-python38/root/usr/include/python3.8 -c pygraphviz/graphviz_wrap.c -o build/temp.linux-x86_64-3.8/pygraphviz/graphviz_wrap.o
In file included from /usr/include/graphviz/gvc.h:17:0,
from pygraphviz/graphviz_wrap.c:2712:
/usr/include/graphviz/types.h:49:20: fatal error: cgraph.h: No such file or directory
#include <cgraph.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1

ERROR: Failed building wheel for pygraphviz

turns out that line 49 in /usr/include/graphviz/types.h was something like: #include <cgraph.h>
once changed to #include "cgraph.h" the issue is resolved

@hcstantheman
Copy link

Apple M1 user here. I believe the solution is to provide the correct path for the pip to find the header file.

brew install graphviz will install graphviz onto the computer. but when installing graphviz for python first pip needs to know the location of the graphviz that has previously installed.

in my case the homebrew chose to install graphviz in this directory:

/opt/homebrew/Cellar/graphviz/8.0.1/

so with additional flag specifying the header files and lib it should be fine:

pip install --install-option="--include-path=/opt/homebrew/Cellar/graphviz/8.0.1/include/" --install-option="--library-path=/opt/homebrew/Cellar/graphviz/8.0.1/lib" pygraphviz

the path might vary from person to person. just make sure you can find the file and it should work.

@mengchaoheng
Copy link


$ pip3 install --global-option=build_ext --global-option="-I$(brew --prefix graphviz)/include"  --global-option="-L$(brew --prefix graphviz)/lib" pygraphviz                                    

DEPRECATION: --build-option and --global-option are deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use --config-settings. Discussion can be found at https://github.com/pypa/pip/issues/11859
WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option. 
Collecting pygraphviz
  Using cached pygraphviz-1.10.zip (120 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pygraphviz
  WARNING: Ignoring --global-option when building pygraphviz using PEP 517
  Building wheel for pygraphviz (pyproject.toml) ... error
  error: subprocess-exited-with-error

@vtwoptwo
Copy link

vtwoptwo commented Jul 11, 2023

MacOS Apple Silicon 13.4.1 (22F82)

this solved it for me
first:

brew install graphviz

then:

pip install --use-pep517 \
            --config-setting="--global-option=build_ext" \
            --config-setting="--build-option=-I$(brew --prefix graphviz)/include/" \
            --config-setting="--build-option=-L$(brew --prefix graphviz)/lib/" \
            pygraphviz

@MridulS
Copy link
Contributor

MridulS commented Sep 22, 2023

@zikkuratti could you please open a new issue with the exact versions of pygraphviz, graphviz, operating system and how you installed graphviz and pygraphviz? Thanks!

@alexwilson1
Copy link

Had the same problem on Linux aarch64 (ARM). Solved it like this with inspiration from the reply above:

sudo apt install libgraphviz-dev
export C_INCLUDE_PATH="/usr/include/graphviz:$C_INCLUDE_PATH"
export LIBRARY_PATH="/usr/lib/aarch64-linux-gnu/graphviz:$LIBRARY_PATH"
pip install --use-pep517 pygraphviz

I tried this format:

pip install --use-pep517 \
            --config-setting="--global-option=build_ext" \
            --config-setting="--build-option=-I/usr/include/graphviz" \
            --config-setting="--build-option=-L/usr/lib/aarch64-linux-gnu/graphviz" \
            pygraphviz

But it gave me the error:

      error: option -L not recognized
      [end of output]

@lordgrenville
Copy link

On Mac M3 MacOS 14.2.1, I tried unsuccessfully:

brew install graphviz
pip install --use-pep517 \
            --config-setting="--global-option=build_ext" \
            --config-setting="--build-option=-I$(brew --prefix graphviz)/include/" \
            --config-setting="--build-option=-L$(brew --prefix graphviz)/lib/" \
            pygraphviz

I had to add the paths as environment variables:

export C_INCLUDE_PATH="$(brew --prefix graphviz)/include/"
export C_LIBRARY_PATH="$(brew --prefix graphviz)/lib/"
pip install --use-pep517 --config-setting="--global-option=build_ext" pygraphviz

Which worked.

@mikolysz
Copy link

Also on Mac OS 14 M1, had the same problem.

The fix from the previous comment didn't work for me, but this did:

export C_INCLUDE_PATH="$(brew --prefix graphviz)/include/"
export LIBRARY_PATH="$(brew --prefix graphviz)/lib/"
pip install --use-pep517 --config-setting="--global-option=build_ext" pygraphviz

@nuosv
Copy link

nuosv commented Jul 28, 2024

This is a fucking joke, 4 years and still the same issue for windows 10?

@marcinpraczko
Copy link

marcinpraczko commented Aug 8, 2024

On Ubuntu (Docker) - I had the same issue - this was resolved by installing proper DEV packages. This is what worked for me.

Ubuntu details:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04 LTS"
PRETTY_NAME="Ubuntu 24.04 LTS"

Installing packages:

    apt-get -y install \
        python3-pip \
        python3-venv \
        graphviz \
        libgraphviz-dev   ## This is installing proper DEV headers files.

Installed PIP packages:

pygraphviz==1.13

And things started working as expected

@helloworlde
Copy link

conda install pygraphviz might be easier

This worked for me on Ubuntu 22.04

@mcDandy
Copy link

mcDandy commented Nov 9, 2024

Still a problem. Do not know why. I am on windows 11

Tried python -m pip install --global-option=build_ext --global-option="IC:\Program Files\Graphviz\include" --global-option="LC:\Program Files\Graphviz\bin" pygraphviz pip install pygraphviz. No luck. I don't have conda setup.

DEPRECATION: --build-option and --global-option are deprecated. pip 25.0 will enforce this behaviour change. A possible replacement is to use --config-settings. Discussion can be found at https://github.com/pypa/pip/issues/11859
WARNING: Implying --no-binary=:all: due to the presence of --build-option / --global-option.
WARNING: Ignoring invalid distribution ~term (F:\Program Files\Python312\Lib\site-packages)
Collecting pygraphviz
  Using cached pygraphviz-1.14.tar.gz (106 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pygraphviz
  WARNING: Ignoring --global-option when building pygraphviz using PEP 517
  Building wheel for pygraphviz (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pygraphviz (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [54 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build\lib.win-amd64-cpython-312\pygraphviz
      copying pygraphviz\agraph.py -> build\lib.win-amd64-cpython-312\pygraphviz
      copying pygraphviz\graphviz.py -> build\lib.win-amd64-cpython-312\pygraphviz
      copying pygraphviz\scraper.py -> build\lib.win-amd64-cpython-312\pygraphviz
      copying pygraphviz\testing.py -> build\lib.win-amd64-cpython-312\pygraphviz
      copying pygraphviz\__init__.py -> build\lib.win-amd64-cpython-312\pygraphviz
      creating build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_attribute_defaults.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_clear.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_close.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_drawing.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_edge_attributes.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_graph.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_html.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_layout.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_node_attributes.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_readwrite.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_repr_mimebundle.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_scraper.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_string.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_subgraph.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\test_unicode.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      copying pygraphviz\tests\__init__.py -> build\lib.win-amd64-cpython-312\pygraphviz\tests
      running egg_info
      writing pygraphviz.egg-info\PKG-INFO
      writing dependency_links to pygraphviz.egg-info\dependency_links.txt
      writing top-level names to pygraphviz.egg-info\top_level.txt
      reading manifest file 'pygraphviz.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no files found matching '*.swg'
      warning: no files found matching '*.png' under directory 'doc'
      warning: no files found matching '*.html' under directory 'doc'
      warning: no files found matching '*.txt' under directory 'doc'
      warning: no files found matching '*.css' under directory 'doc'
      warning: no previously-included files matching '*~' found anywhere in distribution
      warning: no previously-included files matching '*.pyc' found anywhere in distribution
      warning: no previously-included files matching '.svn' found anywhere in distribution
      no previously-included directories found matching 'doc\build'
      adding license file 'LICENSE'
      writing manifest file 'pygraphviz.egg-info\SOURCES.txt'
      copying pygraphviz\graphviz.i -> build\lib.win-amd64-cpython-312\pygraphviz
      copying pygraphviz\graphviz_wrap.c -> build\lib.win-amd64-cpython-312\pygraphviz
      running build_ext
      building 'pygraphviz._graphviz' extension
      creating build\temp.win-amd64-cpython-312\Release\pygraphviz
      "F:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DSWIG_PYTHON_STRICT_BYTE_CHAR -DGVDLL "-IF:\Program Files\Python312\include" "-IF:\Program Files\Python312\Include" "-IF:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include" "-IF:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\ATLMFC\include" "-IF:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IF:\Windows Kits\10\include\10.0.22621.0\ucrt" "-IF:\Windows Kits\10\\include\10.0.22621.0\\um" "-IF:\Windows Kits\10\\include\10.0.22621.0\\shared" "-IF:\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IF:\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-cpython-312\Release\pygraphviz/graphviz_wrap.obj
      graphviz_wrap.c
      pygraphviz/graphviz_wrap.c(9): warning C4005: SWIG_PYTHON_STRICT_BYTE_CHAR: pýedefinov nˇ makra
      pygraphviz/graphviz_wrap.c(9): note: SWIG_PYTHON_STRICT_BYTE_CHAR dýˇve deklarovan‚ na pýˇkazov‚m ý dku
      pygraphviz/graphviz_wrap.c(3023): fatal error C1083: Nejde otevýˇt soubor zahrnout: graphviz/cgraph.h: No such file or directory
      error: command 'F:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pygraphviz
Failed to build pygraphviz
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (pygraphviz)

@danwilhelm
Copy link

danwilhelm commented Jan 4, 2025

In Ubuntu, I got the mentioned error when only running pip.

However, it worked after first installing graphviz and graphviz-dev (i.e. properly following the instructions in the README):

sudo apt-get install graphviz graphviz-dev
pip install pygraphviz

@alexandrubordei
Copy link

This worked for me on Windows 11 and graphviz-12.2.1 Python 3.12.8

python -m pip install --config-setting="--global-option=build_ext" --config-setting="--global-option=-IC:\Program Files\Graphviz\include" --config-settings="--global-option=-LC:\Program Files\Graphviz\lib" pygraphviz

@tanweer-mahdi
Copy link

tanweer-mahdi commented Feb 22, 2025

Extending @mikolysz 's useful answer for extending to the uv package manager. Worked for me in MacOS 15.3.

export C_INCLUDE_PATH="$(brew --prefix graphviz)/include/"
export LIBRARY_PATH="$(brew --prefix graphviz)/lib/"
uv pip install --config-setting="--global-option=build_ext" pygraphviz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests