kylebarron / stata_kernel

A Jupyter kernel for Stata. Works with Windows, macOS, and Linux.
https://kylebarron.dev/stata_kernel/
GNU General Public License v3.0
267 stars 57 forks source link

IFrame plots don't display on Edge on Windows #283

Open amichuda opened 5 years ago

amichuda commented 5 years ago

Hi,

Yet another problem I've run into. On Windows computers, the stata kernel works and makes output for regressions and what have you, but plots don't display. There's only a large amount of whitespace for where the plot should be. Any ideas as to why this might be happening? The console doesn't seem to show a problem, but is there a log file somewhere that I can get you more information?

kylebarron commented 5 years ago

Can you give a reproducible example?

kylebarron commented 5 years ago

The bug report template explains the log file https://github.com/kylebarron/stata_kernel/issues/new?template=bug_report.md

Hemken commented 5 years ago

My example would be:

sysuse auto
twoway (scatter mpg weight) (lfit mpg weight)

The first time I installed stata_kernel, running python -m stata_kernel.install as an ordinary user, my example worked fine. After trying to uninstall the individual configuration file and re-running (as admin) python -m stata_kernel.install --sys-prefix, graphs give me the behavior "lordflaron" describes: a large empty space where I expect to see a graph (as if something invisible is embedded there?)

kylebarron commented 5 years ago

I just uninstalled and reinstalled stata_kernel and it seems to work for me, even with --sys-prefix. image

I'm not intricately familiar with how --sys-prefix works. Here are a few things you can do to help debug this:

Hemken commented 5 years ago

Let me amend that: in the .stata_kernel_cache I find both a .pdf and an .svg version of my graph, it just isn't rendered in Jupyterlab for some reason. If I rerun the cell, I get new versions of both, so this is not a Stata problem.

When I export as a PDF, I get the full document. When I export as HTML, I get the same blank space. If I look at the HTML source, I find SVG instructions (generated by Stata) for the graph, see attached Stata_kernel tests.zip Stata_kernel tests.zip

Hemken commented 5 years ago

This is on Windows 10, Stata 15.1. I've been using your uninstall instructions as well.

kylebarron commented 5 years ago

Ok, cool. Which browser are you using? This might be related to the attempted fix of https://github.com/kylebarron/stata_kernel/issues/234.

Hemken commented 5 years ago

Edge

kylebarron commented 5 years ago

I just tried it out on Edge on Windows 10 and I can reproduce your issue.

You can read through #234 to see the annoying problem we were trying to solve. Basically, SVG images were interfering with each other, and the way we solved that was by putting each SVG image inside an <iframe> tag. Apparently that works fine on all browsers but IE/Edge. StataCorp acknowledged a bug, but a fix won't come out until the next major or minor release, and who knows when that will be.

Easy solutions:

Hemken commented 5 years ago

If I open the saved HTML file in Chrome, everything is good. Also good in Firefox.

I did read through that issue. In the past I have found and reported a number of bugs in Stata's graphs (visible within the Stata IDE).

We'll probably go with the PNG advice, and try the --sys-prefix route again. Can I set this (png) within Stata? My users will be more familiar with Stata than with Python.

Lots of software has both site and personal config options ... just sayin' ! Great kernel though, thanks for putting it together. We'll be using this for teaching, beginning in a couple of weeks.

kylebarron commented 5 years ago

We'll probably go with the PNG advice, and try the --sys-prefix route again. Can I set this (png) within Stata? My users will be more familiar with Stata than with Python.

Yes. %set is run inside Stata when using stata_kernel. There are several such commands, called magics that provide extra functionality.

image

Lots of software has both site and personal config options ... just sayin' ! Great kernel though, thanks for putting it together. We'll be using this for teaching, beginning in a couple of weeks.

Yes, I agree, and it's definitely a good feature, but I don't have as much time for new features at the moment. This in particular would probably be pretty easy to implement. Though I'm not sure what the usual system-wide configuration file locations are on Windows.

kylebarron commented 5 years ago

I added this to the troubleshooting docs page. https://kylebarron.github.io/stata_kernel/using_stata_kernel/troubleshooting/#graphs-wont-display

Hemken commented 5 years ago

So many problems with graphics! SVG renders more sharply, but the axis is clipped on the right (both Chrome and Firefox, so this is likely a Stata issue)! At least the PDF is both clear and unclipped. PNG must be specified in the %magic, not in the Stata code.

In case it’s useful: As for site configs, I find kernelspecs in c:\ProgramData\jupyter\kernels (R, for example, when installed for everyone). And also in c:\ProgramData\Anaconda3\share\jupyter\kernels (Python itself, for example).

I also have 4 different kernels that ended up in my personal \AppData\Roaming\jupyter\kernels (Stata, SAS, Julia, and another version of R) (different computer, different OS).

From: Kyle Barron [mailto:notifications@github.com] Sent: Thursday, January 10, 2019 1:54 PM To: kylebarron/stata_kernel stata_kernel@noreply.github.com Cc: Doug Hemken dehemken@wisc.edu; Comment comment@noreply.github.com Subject: Re: [kylebarron/stata_kernel] Plots don't display (#283)

I added this to the troubleshooting docs page. https://kylebarron.github.io/stata_kernel/using_stata_kernel/troubleshooting/#graphs-wont-display

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/kylebarron/stata_kernel/issues/283#issuecomment-453231400, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALAWE6T6VZYCxOP4ubw6YtFDVe3paDXEks5vB5pegaJpZM4Z4rrs.

Hemken commented 5 years ago

I suppose I should mention that the syntax highlighting hung when I tried to install it, so I’ve just given up on that. I’m not that strongly interested, anyway.

From: Kyle Barron [mailto:notifications@github.com] Sent: Thursday, January 10, 2019 1:54 PM To: kylebarron/stata_kernel stata_kernel@noreply.github.com Cc: Doug Hemken dehemken@wisc.edu; Comment comment@noreply.github.com Subject: Re: [kylebarron/stata_kernel] Plots don't display (#283)

I added this to the troubleshooting docs page. https://kylebarron.github.io/stata_kernel/using_stata_kernel/troubleshooting/#graphs-wont-display

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/kylebarron/stata_kernel/issues/283#issuecomment-453231400, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALAWE6T6VZYCxOP4ubw6YtFDVe3paDXEks5vB5pegaJpZM4Z4rrs.

kylebarron commented 5 years ago

the axis is clipped on the right (both Chrome and Firefox, so this is likely a Stata issue)!

Can you give an example of this?

kylebarron commented 5 years ago

I suppose I should mention that the syntax highlighting hung when I tried to install it, so I’ve just given up on that. I’m not that strongly interested, anyway.

Can you run ctrl-C and try again? It's worked for me each time I've tried to install.

Hemken commented 5 years ago

In the image you produced, the “5,000” on the x axis is clipped. Same for me in both browsers. Consistent with other Stata graphics problems, probably not Jupyter or stata_kernel in my opinion.

From: Kyle Barron [mailto:notifications@github.com] Sent: Thursday, January 10, 2019 2:23 PM To: kylebarron/stata_kernel stata_kernel@noreply.github.com Cc: Doug Hemken dehemken@wisc.edu; Comment comment@noreply.github.com Subject: Re: [kylebarron/stata_kernel] Plots don't display (#283)

the axis is clipped on the right (both Chrome and Firefox, so this is likely a Stata issue)!

Can you give an example of this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/kylebarron/stata_kernel/issues/283#issuecomment-453240339, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALAWE2-zhiML95Nt_GRCkp9bzi1-Uofeks5vB6E1gaJpZM4Z4rrs.

Hemken commented 5 years ago

I tried it multiple times, on two different computers (windows 10 and windows 7). Still trying to recover the Windows 7 machine, if I can figure out how to uninstall. Never would finish installing (even overnight).

From: Kyle Barron [mailto:notifications@github.com] Sent: Thursday, January 10, 2019 2:24 PM To: kylebarron/stata_kernel stata_kernel@noreply.github.com Cc: Doug Hemken dehemken@wisc.edu; Comment comment@noreply.github.com Subject: Re: [kylebarron/stata_kernel] Plots don't display (#283)

I suppose I should mention that the syntax highlighting hung when I tried to install it, so I’ve just given up on that. I’m not that strongly interested, anyway.

Can you run ctrl-C and try again? It's worked for me each time I've tried to install.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/kylebarron/stata_kernel/issues/283#issuecomment-453240528, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALAWEwy5iVao2Z5N47Aj0OAZ3c2Zezqrks5vB6FagaJpZM4Z4rrs.

kylebarron commented 5 years ago

Ok, I've only tried on Windows 10. You did run the command to install node, right? What was the last thing printed to the console where it stopped?

Hemken commented 5 years ago

Yup, ran both

conda install -c conda-forge nodejs -y jupyter labextension install jupyterlab-stata-highlight

and it hung on a message that said it was installing jupyterlab-stata-highlight.tgz or some such. Got through all the preliminaries and hung on the main package.

Hemken commented 5 years ago

Same place on both OS's.

kylebarron commented 5 years ago

Are you behind a firewall? I think that means it wasn't able to download it.

Hemken commented 5 years ago

I’ll look into that.

kylebarron commented 5 years ago

To test, download the library separately (go here and download and extract the files) then run jupyter labextension install ./path/to/unzipped/folder.

Hemken commented 5 years ago

Downloaded. I have one test machine each of Windows 10 and Windows 7 running properly without, going to wait until our sysadmin can get that pushed out, then I'll test further. Could be tomorrow, could be next week, but I'll get back to you ... I appreciate having a willing guinea pig, myself.