SylarSong
SylarSong

Reputation: 43

How do I install pygraphviz with pip

this is brew list and pip list

(lebienv) ➜  lebi git:(master) ✗ brew list
graphviz    libpng      libxml2     mysql       openssl
(lebienv) ➜  lebi git:(master) ✗ pip list
Flask (0.10.1)
itsdangerous (0.24)
Jinja2 (2.8)
MarkupSafe (0.23)
pip (8.0.3)
setuptools (20.1.1)
Werkzeug (0.11.4)
wheel (0.29.0)
(lebienv) ➜  lebi git:(master) ✗

and excute pip install pygraphviz

(lebienv) ➜  lebi git:(master) ✗ pip install pygraphviz
Collecting pygraphviz
  Using cached pygraphviz-1.3.1.tar.gz
Building wheels for collected packages: pygraphviz
  Running setup.py bdist_wheel for pygraphviz ... error
  Complete output from command /Users/zyl/song/lebi/lebienv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/tmp7z72M3pip-wheel- --python-tag cp27:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.11-intel-2.7
  creating build/lib.macosx-10.11-intel-2.7/pygraphviz
  copying pygraphviz/__init__.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
  copying pygraphviz/agraph.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
  copying pygraphviz/graphviz.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
  copying pygraphviz/release.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
  copying pygraphviz/version.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz
  creating build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/__init__.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_attribute_defaults.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_attributes.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_clear.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_drawing.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_edge_attributes.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_graph.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_html.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_layout.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_node_attributes.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_readwrite.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_string.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_subgraph.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  copying pygraphviz/tests/test_unicode.py -> build/lib.macosx-10.11-intel-2.7/pygraphviz/tests
  running egg_info
  writing pygraphviz.egg-info/PKG-INFO
  writing top-level names to pygraphviz.egg-info/top_level.txt
  writing dependency_links to pygraphviz.egg-info/dependency_links.txt
  warning: manifest_maker: standard file '-c' not found

  reading manifest file 'pygraphviz.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  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.11-intel-2.7/pygraphviz
  copying pygraphviz/graphviz_wrap.c -> build/lib.macosx-10.11-intel-2.7/pygraphviz
  running build_ext
  building 'pygraphviz._graphviz' extension
  creating build/temp.macosx-10.11-intel-2.7
  creating build/temp.macosx-10.11-intel-2.7/pygraphviz
  cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pygraphviz/graphviz_wrap.c -o build/temp.macosx-10.11-intel-2.7/pygraphviz/graphviz_wrap.o
  pygraphviz/graphviz_wrap.c:3321:12: warning: incompatible pointer to integer conversion returning 'Agsym_t *' (aka 'struct Agsym_s *') from a function with result type 'int' [-Wint-conversion]
      return agattr(g, kind, name, val);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
  pygraphviz/graphviz_wrap.c:3405:7: warning: unused variable 'fd1' [-Wunused-variable]
    int fd1 ;
        ^
  pygraphviz/graphviz_wrap.c:3406:13: warning: unused variable 'mode_obj1' [-Wunused-variable]
    PyObject *mode_obj1 ;
              ^
  pygraphviz/graphviz_wrap.c:3407:13: warning: unused variable 'mode_byte_obj1' [-Wunused-variable]
    PyObject *mode_byte_obj1 ;
              ^
  pygraphviz/graphviz_wrap.c:3408:9: warning: unused variable 'mode1' [-Wunused-variable]
    char *mode1 ;
          ^
  pygraphviz/graphviz_wrap.c:3463:7: warning: unused variable 'fd2' [-Wunused-variable]
    int fd2 ;
        ^
  pygraphviz/graphviz_wrap.c:3464:13: warning: unused variable 'mode_obj2' [-Wunused-variable]
    PyObject *mode_obj2 ;
              ^
  pygraphviz/graphviz_wrap.c:3465:13: warning: unused variable 'mode_byte_obj2' [-Wunused-variable]
    PyObject *mode_byte_obj2 ;
              ^
  pygraphviz/graphviz_wrap.c:3466:9: warning: unused variable 'mode2' [-Wunused-variable]
    char *mode2 ;
          ^
  9 warnings generated.
  pygraphviz/graphviz_wrap.c:3295:15: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
          len = strlen(val);
              ~ ^~~~~~~~~~~
  pygraphviz/graphviz_wrap.c:3321:12: warning: incompatible pointer to integer conversion returning 'Agsym_t *' (aka 'struct Agsym_s *') from a function with result type 'int' [-Wint-conversion]
      return agattr(g, kind, name, val);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~
  pygraphviz/graphviz_wrap.c:3313:15: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
          len = strlen(val);
              ~ ^~~~~~~~~~~
  pygraphviz/graphviz_wrap.c:3405:7: warning: unused variable 'fd1' [-Wunused-variable]
    int fd1 ;
        ^
  pygraphviz/graphviz_wrap.c:3406:13: warning: unused variable 'mode_obj1' [-Wunused-variable]
    PyObject *mode_obj1 ;
              ^
  pygraphviz/graphviz_wrap.c:3407:13: warning: unused variable 'mode_byte_obj1' [-Wunused-variable]
    PyObject *mode_byte_obj1 ;
              ^
  pygraphviz/graphviz_wrap.c:3408:9: warning: unused variable 'mode1' [-Wunused-variable]
    char *mode1 ;
          ^
  pygraphviz/graphviz_wrap.c:3463:7: warning: unused variable 'fd2' [-Wunused-variable]
    int fd2 ;
        ^
  pygraphviz/graphviz_wrap.c:3464:13: warning: unused variable 'mode_obj2' [-Wunused-variable]
    PyObject *mode_obj2 ;
              ^
  pygraphviz/graphviz_wrap.c:3465:13: warning: unused variable 'mode_byte_obj2' [-Wunused-variable]
    PyObject *mode_byte_obj2 ;
              ^
  pygraphviz/graphviz_wrap.c:3466:9: warning: unused variable 'mode2' [-Wunused-variable]
    char *mode2 ;
          ^
  11 warnings generated.
  cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/pygraphviz/graphviz_wrap.o -lcgraph -lcdt -o build/lib.macosx-10.11-intel-2.7/pygraphviz/_graphviz.so
  ld: warning: ignoring file /usr/local/lib/libcdt.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libcdt.dylib
  ld: warning: ignoring file /usr/local/lib/libcgraph.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libcgraph.dylib
  installing to build/bdist.macosx-10.11-intel/wheel
  running install
  Trying pkg-config
  Failed to find pkg-config
  Trying dotneato-config
  Failed to find dotneato-config
  Failed to find dotneato-config

  Your Graphviz installation could not be found.

          1) You don't have Graphviz installed:
             Install Graphviz (http://graphviz.org)

          2) Your Graphviz package might incomplete.
             Install the binary development subpackage (e.g. libgraphviz-dev or similar.)

          3) You are using Windows
             There are no PyGraphviz binary packages for Windows but you might be
             able to build it from this source.  See
             http://networkx.lanl.gov/pygraphviz/reference/faq.html

          If you think your installation is correct you will need to manually
          change the include_dirs and library_dirs variables in setup.py to
          point to the correct locations of your graphviz installation.

          The current setting of library_dirs and include_dirs is:
  library_dirs=None
  include_dirs=None

  error: Error locating graphviz.

  ----------------------------------------
  Failed building wheel for pygraphviz
  Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... error
    Complete output from command /Users/zyl/song/lebi/lebienv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-1imEXi-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zyl/song/lebi/lebienv/include/site/python2.7/pygraphviz:
    running install
    Trying pkg-config
    Failed to find pkg-config
    Trying dotneato-config
    Failed to find dotneato-config
    Failed to find dotneato-config

    Your Graphviz installation could not be found.

            1) You don't have Graphviz installed:
               Install Graphviz (http://graphviz.org)

            2) Your Graphviz package might incomplete.
               Install the binary development subpackage (e.g. libgraphviz-dev or similar.)

            3) You are using Windows
               There are no PyGraphviz binary packages for Windows but you might be
               able to build it from this source.  See
               http://networkx.lanl.gov/pygraphviz/reference/faq.html

            If you think your installation is correct you will need to manually
            change the include_dirs and library_dirs variables in setup.py to
            point to the correct locations of your graphviz installation.

            The current setting of library_dirs and include_dirs is:
    library_dirs=None
    include_dirs=None

    error: Error locating graphviz.

    ----------------------------------------
Command "/Users/zyl/song/lebi/lebienv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-1imEXi-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/zyl/song/lebi/lebienv/include/site/python2.7/pygraphviz" failed with error code 1 in /private/var/folders/5t/965cgdc56ks37w8pmlmw4vx40000gn/T/pip-build-x2Vstw/pygraphviz

System :Mac OS X Version:10.11.1

how to fix the problem.

Upvotes: 4

Views: 11727

Answers (5)

Yuri Santos
Yuri Santos

Reputation: 67

The @jamjar and @Faccion answers did not work properly for me. So, I looked at the documentation and found a path config that worked for me. (Remember to install grapgviz first)

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

documentation: https://pygraphviz.github.io/documentation/stable/install.html#manual-download

Upvotes: 0

Sameer Mahajan
Sameer Mahajan

Reputation: 598

latest pip versions (e.g. 24.2 and later) have deprecated the --build-option and --global-option for newer --config-settings as can be seen here

DEPRECATION: --build-option and --global-option are deprecated. pip 24.2 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

Now you need something like

pip install --config-settings="--build-option=build_ext" --config-settings="--build-option=--library-dirs=$GRAPHVIZ_DIR/lib" --config-settings="--build-option=--include-dirs=$GRAPHVIZ_DIR/include" pygraphviz

where $GRAPHVIZ_DIR is the directory where you have installed graphviz

Upvotes: 0

Rob
Rob

Reputation: 1909

It is not helpful to randomly attempt to paste in people's paths for the install location.

If you installed it successfully with brew, you can get your own path and use it to install pygraphviz:

brew install graphviz
brew info graphviz
# This will print out the install location
# Look for this line:
# **/usr/local/Cellar/graphviz/3.0.0** (292 files, 6.8MB) *
# Path is part I've bolded above

export GRAPHVIZ_DIR="[path from above command]"
# Ensure you are in the virtual environment
pip install pygraphviz --global-option=build_ext --global-option="-I$GRAPHVIZ_DIR/include" --global-option="-L$GRAPHVIZ_DIR/lib"

Upvotes: 2

jamjar
jamjar

Reputation: 635

Setting library_dirs and include_dirs as suggested in the error message worked for me. This article shows how to set them. However, first make sure pygraphviz is actually installed.

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

Upvotes: 3

Faccion
Faccion

Reputation: 274

Have you tried

pip install git+git://github.com/pygraphviz/pygraphviz.git

as suggested in this issue ?

Upvotes: 2

Related Questions