Unable to show the print output of my notebook

Sorry to ask a very basic question but I am unable to show the results of my notebook here

I have tried all the solutions mentioned in Stack Overflow but none of them work.

Here are some of the SO solutions I tried -

  1. Print not showing on github

Can someone provide some guidance ?

Regards,
Ashwin,

you need to run the notebook inside a jupyter environment.

the code itself works, though posting an api key publicly might not be such a good idea o.O

Yes I have deleted the files.

But I have the same problem with this notebook - vortdivinversion/Vorticity_Divergence_Inversion.ipynb at 02bc8315116bc8f2e22b2eabfe37859b0abade43 ¡ winash12/vortdivinversion ¡ GitHub

As a newbie can you explain what is meant by running inside a jupyter environment ? The .ipynb file is sitting on the github site. How can I make that file render my plots ?

there are a lot of ways to run .ipynb files.

you could install jupyterlab desktop for example and open the ipynb file there. run the cell and save the file with the generated output. then push the file back to github and the output will be visible then.

other ways to run a ipynb:

  • through jupyterlab in the browser (installt with pip install jupyterlab and then run with jupyer lab)
  • through visual studio code with jupyter extension installed
  • through pycharm
  • etc.

If your notebooks had the output saved in them then probably you could have used nbviewer to render the output and plots. For example, with your latest .ipynb file that would be https://nbviewer.org/github/winash12/vortdivinversion/blob/master/Vorticity_Divergence_Inversion.ipynb. You’ll note the URL follows a pattern. However, you can always go to the main nbviewer page and it will generate the link using the form.

Nbviewer is capable of displaying a lot more output types than the GitHub preview does. For example, Plotly plots display and remain active in nbviewer whereas they don’t render int he GitHub preview meant for developers, see here & bottom paragraph here for more details.

However, if you look into the actual code here for your latest example, you’ll see every input cell you have with code, has "outputs": []. This means there’s no saved output. After you run the notebook, save it with the cells run.

In addition to what spookster said, you may wish to read about using the MyBinder service and JupyterLite here. The perspective there was focused on drafting notebooks; however, it was also meant for running them.
However, the notebook you’ve supplied as an example is not a simple one and may not work there. “As a newbie”, you’d want to start with simpler examples. For example go here and click ‘launch binder’ and work on running that notebook that comes up and saving it run and then downloading it to your machine. And then put it on the internet and point nbviewer at it. Start in the shallow end when learning. Not something as complex as you bring up.

I actually did try to run it with MyBinder-served session and got to about four or five cells in before I ran into issues where the code and the environment were sympatico, presumably. See Jupyter Notebook Viewer where I put the step-by-step of getting that far in at the top and you can see a plot showing in the displayed output if you scrolll down to the output of the 5th input cell.

I should also point out that the one you bring up isn’t going to work on JupyterLite as it involves a lot of network access.

In the future, specify details. We cannot tell what you tried or didn’t try based on a vague statement that you tried all the solutions mentioned in StackOveflow. Please read Getting good answers to your questions. Pay particular attention to the admonition ’ Make sure to keep track of what you find when researching, even if it doesn’t help! If you ultimately aren’t able to find the answer to your question elsewhere on this site, then including links to related questions (as well as an explanation of why they didn’t help in your specific case) will help’, under the section ‘Search, and Research’, in the link to How do I ask a good question? at the bottom there.

1 Like

I have since added a link to my original post but when I tried to add a second link I got an error message saying that as a new user I cannot add more than 1 link to a post.

Regarding saving the image - this notebook from a colleague is identical to mine but he does save the cells as far as I can tell and yet he is able to render perfectly

Rendering vorticity notebook

Your colleague saved the run notebook and so the output from the input cells is present and so it works, as spookster and I told you it would. (Assuming GitHub can render that type of output and it isn’t too large from that service to try and deal with.) Ideally use nbviewer because you’ll have a better experience. GitHub can render some things. nbviewer can render more.


I am going to update my post above because I did try to run a few cells of that latest notebook with MyBinder; however, I hit an issue with the code not quite matching with what I think the software expects. You’ll see at least a related plot shows up in GitHub (here) and nbviewer here. The nbviewer rendering is less cluttered and meant for sharing whereas the Github preview is meant for the developer of the repo or fellow developers. Both use the same content, the github content, as the source. If there were more complex output present, it would be more likely to work in nbviewer than the GitHub preview.

Based on your supplying a colleagues example notebook, I have been able to run a more complete notebook in a MyBinder session. Then I saved it and stored it as a gist.

It can be viewer as the nbviewer rendering here with the steps to running that in a session served by MyBinder placed in the top, before the content that was in your colleagues’ Jupyter .ipynb file.

The output & plots all show nicely for the first 10 input cells as expected. It seems to hang on running the 11th cell (it may eventually complete if it doesn’t crash, but so far it is hanging for a long time) and so now I just uploaded with that part run. (Later, it seemed the kernel crashed without completing that cell. It may be because of limited resources provided in MyBinder-served sessions. Something like this would be a limitation and mean you’ll need more computational resources via your own local machine or a cloud-based machine/JupyterHub.)

The posting of this effort provides a good example of the issues you may see via GitHub’s preview AS IT IS IMPERFECT (at this time) & MORE LIMITED THAN NBVIEWER

If you go here, you’ll see Github won’t render the notebook. nbviewer is fine rendering the same content here.

Keep this in mind. Always use the Jupyter Community-provided solution for viewing and sharing notebook content as ‘static’ form. (Or at least check there if you are having problems viewing a notebook in the GitHub preview while viewing the raw code via GitHub’s web browser portal seems to suggest the content is there and intact. I wonder if the % that got added in for the spaces in the file name messed things up with the preview rendering.)

I put ‘static’ in quotes above because some active components like Plotly will render in nbviewer and still be active, where as GitHub currently won’t render these types of javascript-based output.