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

Issue with using objgraph in jupyter console #32

Open
astrofrog opened this issue Oct 27, 2017 · 8 comments
Open

Issue with using objgraph in jupyter console #32

astrofrog opened this issue Oct 27, 2017 · 8 comments

Comments

@astrofrog
Copy link

astrofrog commented Oct 27, 2017

If I use objgraph in an IPython session things work as expected:

In [1]: import objgraph

In [2]: a = 1

In [3]: objgraph.show_backrefs(objgraph.by_type('int'))
Graph written to /var/folders/zy/t1l3sx310d3d6p0kyxqzlrnr0000gr/T/objgraph-5iuhcjwd.dot (0 nodes)
Graph viewer (xdot) not found, generating a png instead
Image generated as /var/folders/zy/t1l3sx310d3d6p0kyxqzlrnr0000gr/T/objgraph-5iuhcjwd.png

However if I use jupyter qtconsole there is no output from show_backrefs, and if I try and specify an output filename, nothing happens:

In [1]: import objgraph

In [2]: a = 1

In [3]: objgraph.show_backrefs(objgraph.by_type('int'))

what could be going on?

@mgedmin
Copy link
Owner

mgedmin commented Oct 30, 2017

objgraph contains code to detect when it's running in Jupyter and display the graph inline in the Jupyter console. This is very likely a bug in that code!

See #23 (comment) and #28 for more details.

Question: do you have https://pypi.python.org/pypi/graphviz installed?

@astrofrog
Copy link
Author

astrofrog commented Oct 30, 2017

@mgedmin - in some cases I do see a graph inline in Jupyter but I still want to have the ability to export the plot to a file (which it doesn't seem to let me do). In the case above the graph is empty which is why I see nothing in the second case. So the inline drawing does work, it's more that it seems to then not allow exporting to files even if asked explicitly. I'll check later today if I had the PyPI graphviz package installed

@mgedmin
Copy link
Owner

mgedmin commented Oct 30, 2017

You should be able to export to a file, if you explicitly specify filename='foo.png' etc. If that doesn't work as well, that could be another bug.

@mgedmin
Copy link
Owner

mgedmin commented Oct 30, 2017

I'm unable to reproduce the problem using Jupyter QtConsole 4.2.1 on Python 3.6.3/IPython 5.1.0:

ekrano nuotrauka is 2017-10-30 16-31-16

@astrofrog
Copy link
Author

You should be able to export to a file, if you explicitly specify filename='foo.png' etc. If that doesn't work as well, that could be another bug.

This is what I was trying and it didn't work either. I'll post specific version information when I'm back at a computer.

@mgedmin
Copy link
Owner

mgedmin commented Dec 30, 2019

You should be able to export to a file, if you explicitly specify filename='foo.png' etc. If that doesn't work as well, that could be another bug.

This is what I was trying and it didn't work either. I'll post specific version information when I'm back at a computer.

That part was broken but is now fixed in a729c40.

@rediffp
Copy link

rediffp commented Oct 20, 2020

I don't know if this issue which happens in environments created in conda falls under the jurisdiction of this issue. The environment in question is Python 3.7.9 <build - h60c2a47_0> made by conda. I installed Graphviz 2.38 <build - hfd603c8_2> from conda, Objgraph 3.5.0, python-graphviz 0.14.2 and xdot 1.1 from pip. To test the setup out, I ran the basic code given in the documentation (yes, the very first one). The xdot package was not detected I guess.
An example. Look at the python console at the bottom left.
p.s. - I'm sorry for necroposting.

@mgedmin
Copy link
Owner

mgedmin commented Oct 20, 2020

@rediffp is the dot tool on your $PATH? If yes, please file another bug because the detection in objgraph is broken. If not, that's your problem and it's not really a bug -- how is objgraph supposed to find a binary executable installed somewhere, when it's not on the PATH?

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

No branches or pull requests

3 participants