Jupyter notebook "Run All" prevents BokehJS from being successfully loaded - jupyter-notebook

If I try to "Run All" cells in a Jupyter notebook, with output_notebook() in the first cell and an attempt to show a figure in a cell below, I get the following error message:
/remote/vgrnd5/davidbr/soft/miniconda3/lib/python3.5/site-packages/bokeh/io.py:350:
UserWarning:
BokehJS does not appear to have successfully loaded. If loading
BokehJS from CDN, this may be due to a slow or bad network connection.
Possible fixes:
ALWAYS run output_notebook() in a cell BY ITSELF, AT THE TOP, with no other code
re-rerun output_notebook() to attempt to load from CDN again, or
use INLINE resources instead, as so:
from bokeh.resources import INLINE
output_notebook(resources=INLINE)
warnings.warn(_NB_LOAD_WARNING)
BokehJS has been successfully loaded though (from what I see in the output of the first cell), but it looks like it has not been registered somehow, because if I run the first cell and then "Run All Bellow", then it works fine. None of the tricks of the error message work.

UPDATE: this issue has been resolved and the fix will be in 0.12.2
Evidently the behavior of the Notebook when "run all" is used is to queue up all the cell executions first, before the async outputs happen. The causes the warning to trigger spuriously. None of the core devs use "run all" with any regularity, and this specific queuing behavior was unknown. You can follow this issue for updates:
https://github.com/bokeh/bokeh/issues/4987
In particular, as an immediate workaround, there is this :

Related

%debug magic command not working in the Q# Jupyter Notebook environment

As per the documentation provided by Microsoft Azure Quantum at this link , I followed the steps given and installed Q# with Jupyter Notebook, using Anaconda.
I then wrote the following Q# program in a Jupyter Notebook (IQ# kernel) using the code taken from here.
(I am currently using Google Chrome)
open Microsoft.Quantum.Diagnostics;
operation MultiQubitDumpMachineDemo() : Unit {
use qubit = Qubit();
H(qubit);
DumpMachine();
Reset(qubit);
}
When I used the magic commands such as %simulate and %trace, the program executed normally. The DumpMachine result clearly shows the qubit in a superposition of |0> and |1> (measurement probability is 50%), and the trace command printed out the quantum circuit.
%simulate Result
%trace Result
However, when I run the %debug command, the interactive HTML display does not work. The debug control button can display the circuit but, the controls for the chart options do not display the amplitudes, probabilities, or real/imaginary co-efficients.
When I opened the console, I observed the following error, every time I clicked the chart options controls:
Couldn't process kernel message TypeError: state.getDenseAmplitudes is not a function
at fitChart (bundle.js?v=20221015232727:292:32)
at Object.updateChart (bundle.js?v=20221015232727:277:9)
at update (bundle.js?v=20221015232727:811:32)
at bundle.js?v=20221015232727:850:17
at Kernel._handle_iopub_message (main.min.js?v=a4e125c812cb3975203ae429a5b40d180b59b8e4602fcc78390ef4f0dd4d14ac3559189f65f23cd50fd971f98f5842b7746f4182babd20b7ca84e52314bcd4ac:63064:20)
at Kernel._finish_ws_message (main.min.js?v=a4e125c812cb3975203ae429a5b40d180b59b8e4602fcc78390ef4f0dd4d14ac3559189f65f23cd50fd971f98f5842b7746f4182babd20b7ca84e52314bcd4ac:62843:29)
at main.min.js?v=a4e125c812cb3975203ae429a5b40d180b59b8e4602fcc78390ef4f0dd4d14ac3559189f65f23cd50fd971f98f5842b7746f4182babd20b7ca84e52314bcd4ac:62834:44
Error Message
Unfortunately, I am not familiar with this type of error or its possible solutions, so I didn't try anything more than updating the 'iqsharp' package.
Can anyone explain why I'm getting this error, and, if possible, provide with me a solution for the same?
Thanks in advance!

Pyinstaller - the exec outfile works just as expected. But the app output fails (but only on 1 item) without an error

This program is a feature rich GUI (thanks to PySimpleGUI) that formats and displays info. Nothing too sophisticated. Its on a Mac M1 - Big Sur. My compile script below is pretty basic too. One screen of my program has a handful of buttonmenus, and for one item on one button, the app produced by pyinstaller exits the program. But the consul just says "process completed, exit code 0." (means "no error")? And that same item works fine - produces the expected output - if I run the corresponding exec file that pyinstaller produced. (And of course, that item works fine when I run it from within my IDE (PyCharm). So....not to sure where to look. Ideas?
import PyInstaller.__main__
PyInstaller.__main__.run([
'main.py',
'--onefile',
'--clean',
'-y',
'--windowed',
'--icon="zaad.icns"'

R Markdown not showing execute button for other engines

In R Markdown if I have a chunk coded with the normal r chunk wrappers,
```{r}
[R code]
```
A play button will appear. However, when I run a chunk wrapped like so for other language engines:
```{python}
[python code]
```
or replacing python replaced with bash/sh, I don't get a play button on the right.
Is there a package I need to install? I restarted Rstudio, and even downloaded the Lesson 5: https://rmarkdown.rstudio.com/lesson-5.html , which even shows those play buttons, and I still don't get it. I am on a mac, and saw that someone on a Windows computer was able to see the play buttons.
I think you need to install the package "knitr". Try to check that first.
Second, you might need to state explitly where your interpreter for Python is, for instance. Use
{python, engine.path = '/usr/bin/python3'}
YOUR CODE
to see if it works.

What is this error in RStudio: "breakpoints will be activated when the file or function is finished executing"?

I am trying to set a break point inside a function from a package I wrote. I am unsuccessful when clicking next to the line number in Rstudio, the error message looks like:
I am not executing anything. Reloading the package did not help either. What is this error and what can I do about it?
Check out this documentation from RStudio that explains what to do.
Basically, make sure you save your R file, then click the Source button on the toolbar:
Your breakpoint should then turn from a hollow red circle to a full one.
Usually running rm(list=ls()) will do the job.

keyboard shortcut for step out while debugging in rstudio

When I'm debugging, every time, I make a change to the source code, I find myself doing the following since it says, "Debug location is approximate because the source is not available.". Is this 3-step process necessary? Is there an easier way?
> debugSource('~/Desktop/foo1.R')
> debug(myfun1)
> myfun1()
Not sure that this is, what you want, but since you use the tag rstudio, it might help.
Clicking in the left border of the script window in RStudio (next to the line numbers) creates a break point. It is marked by a red circle (it it's inside a function) or a red dot (otherwise). If you now click the source button in RStudio, debugSource is run. If the program encounters a breakpoint, it stops and you are able to examine the state of the program. A breakpoint inside a function stops the code when the function is run (and not when it is sourced). The breakpoint will also work when you run the function from the console as in your example.
The breakpoint remains intact when you change your code. So you have, of course, to source your code after every change, but you don't need to rerun debug every time.
For more information on debugging with RStudio, the following link might be helpful: https://support.rstudio.com/hc/en-us/articles/200713843-Debugging-with-RStudio

Resources