Skip to content
New issue

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

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

Already on GitHub? # to your account

Crash trying to run with generate-graphs #33

Closed
dogo opened this issue Mar 27, 2021 · 7 comments · Fixed by #42
Closed

Crash trying to run with generate-graphs #33

dogo opened this issue Mar 27, 2021 · 7 comments · Fixed by #42

Comments

@dogo
Copy link

dogo commented Mar 27, 2021

I'm trying to run the command below but always crash.

Swift Code Metrics info

swift-code-metrics --version
swift-code-metrics 1.5.1

graphviz info

 brew info graphviz 
graphviz: stable 2.47.0 (bottled), HEAD
Graph visualization software from AT&T and Bell Labs
https://www.graphviz.org/
/usr/local/Cellar/graphviz/2.47.0 (301 files, 10.5MB) *
  Poured from bottle on 2021-03-27 at 12:24:11
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/graphviz.rb
License: EPL-1.0
==> Dependencies
Build: autoconf ✔, automake ✔, bison ✘, pkg-config ✔
Required: gd ✔, gts ✔, libpng ✔, librsvg ✔, libtool ✔, pango ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 79,005 (30 days), 201,535 (90 days), 631,622 (365 days)
install-on-request: 66,252 (30 days), 166,056 (90 days), 507,447 (365 days)
build-error: 0 (30 days)

Run log

swift-code-metrics --source . --artifacts metrics --exclude Pods --generate-graphs
NotificationServiceExtension is not linked with the rest of the project.
NotificationServiceExtension is not linked with the rest of the project.
Traceback (most recent call last):
  File "/usr/local/bin/swift-code-metrics", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/scm.py", line 76, in main
    from ._graphs_renderer import GraphsRender
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/_graphs_renderer.py", line 5, in <module>
    from ._graphs_presenter import GraphPresenter
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/_graphs_presenter.py", line 2, in <module>
    from ._graph_helpers import Graph
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/_graph_helpers.py", line 8, in <module>
    import pygraphviz as pgv
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/__init__.py", line 58, in <module>
    from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute, DotError
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/agraph.py", line 22, in <module>
    from . import graphviz as gv
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/graphviz.py", line 28, in <module>
    _graphviz = swig_import_helper()
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/graphviz.py", line 24, in swig_import_helper
    _mod = imp.load_module('_graphviz', fp, pathname, description)
  File "/usr/local/Cellar/python@3.9/3.9.2_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/local/Cellar/python@3.9/3.9.2_3/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: dlopen(/usr/local/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so, 2): Symbol not found: _PyIOBase_Type
  Referenced from: /usr/local/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so
  Expected in: flat namespace
 in /usr/local/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so
@dogo dogo changed the title Crash trying to run Crash trying to run with generate-graphs Mar 29, 2021
@weibel
Copy link

weibel commented Apr 8, 2021

I had to install pygraphviz v1.5 like this (graphviz is installed from brew)

pip3 install --install-option="--include-path=/usr/local/include/" --install-option="--library-path=/usr/local/opt/" pygraphviz==1.5

On the docs it sounds as the latest pygraphviz 1.7 has solved many setup issues compared to earlier version, but i was not able to make it work with swift-code-metrics

@ericklborges
Copy link

I am facing the same issue with the exact same output as @dogo

@weibel, I tried to downgrade pygraphviz as you suggested, but it was unsuccessful.

Swift Code Metrics info

swift-code-metrics --version

swift-code-metrics 1.5.1

graphviz info

brew info graphviz

graphviz: stable 2.47.0 (bottled), HEAD
Graph visualization software from AT&T and Bell Labs
https://www.graphviz.org/
/usr/local/Cellar/graphviz/2.47.0 (301 files, 10.5MB) *
  Poured from bottle on 2021-04-09 at 15:00:57
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/graphviz.rb
License: EPL-1.0
==> Dependencies
Build: autoconf ✔, automake ✘, bison ✘, pkg-config ✔
Required: gd ✔, gts ✔, libpng ✔, librsvg ✔, libtool ✔, pango ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 84,165 (30 days), 225,532 (90 days), 648,784 (365 days)
install-on-request: 70,881 (30 days), 187,067 (90 days), 524,062 (365 days)
build-error: 0 (30 days)

pygraphviz configuration

pip3 show pygraphviz

Name: pygraphviz
Version: 1.5
Summary: Python interface to Graphviz
Home-page: http://pygraphviz.github.io
Author: Aric Hagberg
Author-email: aric.hagberg@gmail.com
License: BSD
Location: /usr/local/lib/python3.9/site-packages
Requires:
Required-by: swift-code-metrics

Run log

swift-code-metrics --source <source-path> --artifacts <artifacts-path> --generate-graphs

Traceback (most recent call last):
  File "/usr/local/bin/swift-code-metrics", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/scm.py", line 76, in main
    from ._graphs_renderer import GraphsRender
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/_graphs_renderer.py", line 5, in <module>
    from ._graphs_presenter import GraphPresenter
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/_graphs_presenter.py", line 2, in <module>
    from ._graph_helpers import Graph
  File "/usr/local/lib/python3.9/site-packages/swift_code_metrics/_graph_helpers.py", line 8, in <module>
    import pygraphviz as pgv
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/__init__.py", line 58, in <module>
    from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute, DotError
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/agraph.py", line 22, in <module>
    from . import graphviz as gv
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/graphviz.py", line 28, in <module>
    _graphviz = swig_import_helper()
  File "/usr/local/lib/python3.9/site-packages/pygraphviz/graphviz.py", line 24, in swig_import_helper
    _mod = imp.load_module('_graphviz', fp, pathname, description)
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: dlopen(/usr/local/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so, 2): Symbol not found: _PyIOBase_Type
  Referenced from: /usr/local/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so
  Expected in: flat namespace
 in /usr/local/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so

Any thoughts? 🤔

@tfoltzfmr
Copy link

I am having the same issues. I would love for a workaround or a fix.

Swift Code Metrics info

swift-code-metrics --version
swift-code-metrics 1.5.1

graphviz info

  brew info graphviz
graphviz: stable 2.48.0, HEAD
Graph visualization software from AT&T and Bell Labs
https://www.graphviz.org/
/Users/user/homebrew/Cellar/graphviz/2.48.0 (301 files, 8MB) *
  Built from source on 2021-08-10 at 15:16:56
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/graphviz.rb
License: EPL-1.0
==> Dependencies
Build: autoconf ✔, automake ✔, bison ✔, pkg-config ✔
Required: gd ✔, gts ✔, libpng ✔, librsvg ✔, libtool ✔, pango ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 76,979 (30 days), 232,635 (90 days), 757,473 (365 days)
install-on-request: 64,837 (30 days), 195,468 (90 days), 629,770 (365 days)
build-error: 0 (30 days)

Run log

swift-code-metrics --source /Users/user/Desktop/DevelopBranch/<source> --artifacts /Users/user/Desktop/Metrics/firstSet --generate-graphs
Traceback (most recent call last):
  File "/Users/user/homebrew/bin/swift-code-metrics", line 8, in <module>
    sys.exit(main())
  File "/Users/user/homebrew/lib/python3.9/site-packages/swift_code_metrics/scm.py", line 76, in main
    from ._graphs_renderer import GraphsRender
  File "/Users/user/homebrew/lib/python3.9/site-packages/swift_code_metrics/_graphs_renderer.py", line 5, in <module>
    from ._graphs_presenter import GraphPresenter
  File "/Users/user/homebrew/lib/python3.9/site-packages/swift_code_metrics/_graphs_presenter.py", line 2, in <module>
    from ._graph_helpers import Graph
  File "/Users/user/homebrew/lib/python3.9/site-packages/swift_code_metrics/_graph_helpers.py", line 8, in <module>
    import pygraphviz as pgv
  File "/Users/user/homebrew/lib/python3.9/site-packages/pygraphviz/__init__.py", line 58, in <module>
    from .agraph import AGraph, Node, Edge, Attribute, ItemAttribute, DotError
  File "/Users/user/homebrew/lib/python3.9/site-packages/pygraphviz/agraph.py", line 22, in <module>
    from . import graphviz as gv
  File "/Users/user/homebrew/lib/python3.9/site-packages/pygraphviz/graphviz.py", line 28, in <module>
    _graphviz = swig_import_helper()
  File "/Users/user/homebrew/lib/python3.9/site-packages/pygraphviz/graphviz.py", line 24, in swig_import_helper
    _mod = imp.load_module('_graphviz', fp, pathname, description)
  File "/Users/user/homebrew/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "/Users/user/homebrew/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: dlopen(/Users/user/homebrew/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so, 2): Symbol not found: _PyIOBase_Type
  Referenced from: /Users/user/homebrew/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so
  Expected in: flat namespace
 in /Users/user/homebrew/lib/python3.9/site-packages/pygraphviz/_graphviz.cpython-39-darwin.so

@tfoltzfmr
Copy link

I finally got the graphs to work.

pip3 install cmake
pip3 install dlib
brew uninstall --ignore-dependencies python3
brew install python
pip3 install recordclass   
pip3 uninstall pygraphviz
pip3 install pygraphviz

I don't know if all those uninstall and install are required. I checked the function of generating graphs throughout, but it wasn't until I unistalled pygraphviz, then reinstalled it with 1.7 that it worked. I did get a message saying 1.5 was required, but it rand and generated my graphs.

@dogo
Copy link
Author

dogo commented Aug 12, 2021

Thanks @tfoltzfmr !

@matsoftware
Copy link
Owner

I've updated the minimum pygraphviz supported version and added support to M1. Can you try again and see if you're still facing any issues?

@ericklborges
Copy link

@matsoftware, I have updated pygraphviz and installed the version from master.
It worked flawlessly :D

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants