stata_kernel
stata_kernel copied to clipboard
Problem with graphs
I'm running into a problem when making graphs. The cell keeps processing and never finishes (and the * symbol is next to the cell all the time). I was trying to run Example.ipynb on my machine to see if that reproduces the problem. Oddly, when I run:
use "https://stats.idre.ucla.edu/stat/stata/notes/hsb2", clear scatter read math, title("Reading score vs Math score") scatter math science, title("Math score vs Science score")
the cell finishes, but displays only the second and not the first graph.
When I do the same without the second graph:
use "https://stats.idre.ucla.edu/stat/stata/notes/hsb2", clear scatter read math, title("Reading score vs Math score")
the cell hangs. Do you have an idea what could cause this?
Hmm, I definitely had issues with that in the early days of developing the package, but I thought the issues were fixed. Which OS? And can you try to attach the
console_debug.log
file:
$HOME/.stata_kernel_cache/console_debug.log
where $HOME
is your home directory.
Otherwise, I don't have access to stata anymore so there's not too much I can debug.
It's Windows 7 - unfortunately I can't try it on another OS since I only have Stata access there. I've attached the log file!
Also, the notebook looks like this, in case that helps. :)
And what stata kernel version is installed?
pip show stata_kernel
That doesn't return an output for me - is there another way to check the version?
I realized I put the q in the end -- the version is 1.11.2
Well, that is the current version. I had issues with graphs similar to what you're experiencing in the early versions, but thought the issues were fixed. (I don't think I ever tested on Windows 7, but doubt that should make a difference). I'm not sure what I can do, because I'd really need to dig in and see where the connection between the kernel and Stata is failing, and I don't have access to Stata anymore.
Theoretically @mcaceresb might be able to help, though he's quite busy so I wouldn't count on it.
Ok! Is there anything you think I could try (maybe a different Stata version or so)?
I don't have any concrete suggestion. I haven't heard any complaints from other users in a while, so possibly this is a Windows 7 bug. I'm really not sure.
I would like to report the same issue on Mac unfortunately.. (Catalina, if relevant)
@MirtheBoomsma What Stata version are you using?
@timobermeier Apologies I was absent from this convo. Is it possible for you to post the notebook that gave you the original issue?
Stata 13. I used the same notebook as the original poster, it is the example notebook you can find here : https://nbviewer.jupyter.org/github/kylebarron/stata_kernel/blob/master/examples/Example.ipynb
Is it a linesize
issue? Can you try I think set linesize 200
and try again?
Unfortunately no change.. A second strange observation is that when I remove the second scatter graph from the code, and so try out:
use "https://stats.idre.ucla.edu/stat/stata/notes/hsb2", clear scatter read math, title("Reading score vs Math score")
Nothing is shown. No graph at all, and also not the text relating to the "global_stata_kernel_graph_counter".
That's also what @timobermeier reported in the first post. I don't have access to Stata anymore, so it's hard for me to debug this.
I understand, thank you for your time. For what it is worth: The graph is shown, however, in STATA and I can see that it is exported to .stata_kernel_cache/.
@timobermeier Apologies I was absent from this convo. Is it possible for you to post the notebook that gave you the original issue?
I also used the example notebook.
My workaround for Windows, in case it's helpful for anyone, was to use the "session mode" of ipystata (so that all cells can access the same underlying Stata session). That's not available for Linux/Mac though.
Have you tried a different graph formats? If you run
%set graph_format svg
and try again, does it give you the same issue? You can also try with png and pdf as the format.
svg fixes it for me, thanks! :-)
%set graph_format svg --permanently
should keep the change across sessions.
I got the same problem but didn't solve it.Could you please show your example?I couldn't fully understanding the solution, since after I run the code "%set graph_format svg",it doesn't work.
After setting as svg, I receive this problem code:
output-file suffix "svg" not recognized specify correct suffix or specify as() option r(198); r(198); r(198);
Furthermore, I see in STATA that the graph has not been exported to .stata_kernel_cache/.
However, I was able to solve the problem :-) This is how I did it: by keeping execution_mode=automation, using Juypyter Lab instead of Jupyter Notebook and setting:
%set graph_format pdf --permanently
I think Stata 13 doesn't support svg
@MirtheBoomsma @kylebarron Thank you so much! I'll try !
@MirtheBoomsma Stata 13 doesn't support svg. Maybe
%set graph_format pdf
or
%set graph_format png
will help?
This happens to me as well, after setting svg permanently. It doesn't happen consistently, it usually happens after running a while. When it happens, re-running another code cell will show Jupyter 'catching up' with the output from Stata. Then rerunning my graph cell will display properly. It would be great to know what's happening!
Well I'm happy to accept a PR, but I don't expect to spend time on this. I don't use Stata anymore.
@MirtheBoomsma Stata 13 doesn't support svg. Maybe
%set graph_format pdf
or
%set graph_format png
will help?
I had the same issue with stata_kernel version 1.11.2 on Windows 10. I have Stata 14.2 and use the kernel with Atom 1.48.0 and Hydrogen 2.14.3.
The above solution from @mcaceresb works for me. Thanks. I guess the default format is png, and when I set the graph format to png, it produces the figure in an independent Stata window but the kernel keeps processing forever. Changing it to svg works and a figure is displayed within Atom, while "pdf" doesn't really work (kernel says This front-end cannot display the desired image type, but it will stop processing, which is better than the "png" case)
It just cannot display graph, other commands function well.
OS: Windows 10 build 19042.746
Stata: version 14
And I used pip show
to check the requirements list one by one, all packages meet the requirement.
the graph format is already set as png.
the twoway scatter price mpg
command did produce a png file at .stata_kernel_cache, it just cannot display it in the notebook.